xml-xmlbeans-cvs 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/cases/marshal doc.xml
Date Sat, 06 Dec 2003 02:21:53 GMT
zieg        2003/12/05 18:21:53

  Modified:    v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        BaseSimpleTypeConverter.java
                        BooleanTypeConverter.java ByNameUnmarshaller.java
                        ByteTypeConverter.java DecimalTypeConverter.java
                        DoubleTypeConverter.java FloatTypeConverter.java
                        IntTypeConverter.java IntegerTypeConverter.java
                        LongTypeConverter.java ShortTypeConverter.java
                        StringTypeConverter.java UnmarshalContextImpl.java
               v2/test/cases/marshal doc.xml
  Log:
  properly recover from invalid lexical exceptions
  
  Revision  Changes    Path
  1.2       +13 -0     xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/BaseSimpleTypeConverter.java
  
  Index: BaseSimpleTypeConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/BaseSimpleTypeConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BaseSimpleTypeConverter.java	5 Dec 2003 02:45:54 -0000	1.1
  +++ BaseSimpleTypeConverter.java	6 Dec 2003 02:21:53 -0000	1.2
  @@ -71,4 +71,17 @@
       {
       }
   
  +    public final Object unmarshal(UnmarshalContextImpl context)
  +    {
  +        try {
  +            return getObject(context);
  +        }
  +        finally {
  +            assert context.isEndElement();
  +            context.next();
  +        }
  +    }
  +
  +    protected abstract Object getObject(UnmarshalContextImpl context);
  +
   }
  
  
  
  1.2       +1 -3      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/BooleanTypeConverter.java
  
  Index: BooleanTypeConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/BooleanTypeConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BooleanTypeConverter.java	5 Dec 2003 02:45:54 -0000	1.1
  +++ BooleanTypeConverter.java	6 Dec 2003 02:21:53 -0000	1.2
  @@ -61,11 +61,9 @@
   final class BooleanTypeConverter
       extends BaseSimpleTypeConverter
   {
  -    public Object unmarshal(UnmarshalContextImpl context)
  +    protected Object getObject(UnmarshalContextImpl context)
       {
           boolean b = context.getBooleanValue();
  -        assert context.isEndElement();
  -        context.next();
           return Boolean.valueOf(b);
       }
   
  
  
  
  1.5       +21 -5     xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ByNameUnmarshaller.java
  
  Index: ByNameUnmarshaller.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ByNameUnmarshaller.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ByNameUnmarshaller.java	5 Dec 2003 02:45:54 -0000	1.4
  +++ ByNameUnmarshaller.java	6 Dec 2003 02:21:53 -0000	1.5
  @@ -58,6 +58,9 @@
   
   import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
   import org.apache.xmlbeans.impl.binding.bts.ByNameBean;
  +import org.apache.xmlbeans.impl.common.InvalidLexicalValueException;
  +import org.apache.xmlbeans.impl.common.XmlStreamUtils;
  +import org.apache.xmlbeans.XmlError;
   
   final class ByNameUnmarshaller implements TypeUnmarshaller
   {
  @@ -120,8 +123,15 @@
           final TypeUnmarshaller um = prop.getTypeUnmarshaller(context);
           assert um != null;
   
  -        final Object prop_val = um.unmarshal(context);
  -        prop.fill(inter, prop_val);
  +        try {
  +            final Object prop_val = um.unmarshal(context);
  +            prop.fill(inter, prop_val);
  +        }
  +        catch (InvalidLexicalValueException ilve) {
  +            //TODO: add location information
  +            XmlError err = XmlError.forMessage(ilve.getMessage());
  +            context.getErrorCollection().add(err);
  +        }
       }
   
   
  @@ -132,9 +142,15 @@
           final TypeUnmarshaller um = prop.getTypeUnmarshaller(context);
           assert um != null;
   
  -
  -        final Object prop_val = um.unmarshalAttribute(context);
  -        prop.fill(inter, prop_val);
  +        try {
  +            final Object prop_val = um.unmarshalAttribute(context);
  +            prop.fill(inter, prop_val);
  +        }
  +        catch (InvalidLexicalValueException ilve) {
  +            //TODO: add location information
  +            XmlError err = XmlError.forMessage(ilve.getMessage());
  +            context.getErrorCollection().add(err);
  +        }
       }
   
       private void deserializeAttributes(Object inter, UnmarshalContextImpl context)
  
  
  
  1.2       +1 -3      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ByteTypeConverter.java
  
  Index: ByteTypeConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ByteTypeConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ByteTypeConverter.java	5 Dec 2003 02:45:54 -0000	1.1
  +++ ByteTypeConverter.java	6 Dec 2003 02:21:53 -0000	1.2
  @@ -61,11 +61,9 @@
   final class ByteTypeConverter
       extends BaseSimpleTypeConverter
   {
  -    public Object unmarshal(UnmarshalContextImpl context)
  +    protected Object getObject(UnmarshalContextImpl context)
       {
           byte val = context.getByteValue();
  -        assert context.isEndElement();
  -        context.next();
           return new Byte(val);
       }
   
  
  
  
  1.2       +2 -3      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/DecimalTypeConverter.java
  
  Index: DecimalTypeConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/DecimalTypeConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DecimalTypeConverter.java	5 Dec 2003 23:48:22 -0000	1.1
  +++ DecimalTypeConverter.java	6 Dec 2003 02:21:53 -0000	1.2
  @@ -63,11 +63,10 @@
   final class DecimalTypeConverter
       extends BaseSimpleTypeConverter
   {
  -    public Object unmarshal(UnmarshalContextImpl context)
  +
  +    protected Object getObject(UnmarshalContextImpl context)
       {
           BigDecimal val = context.getBigDecimalValue();
  -        assert context.isEndElement();
  -        context.next();
           return val;
       }
   
  
  
  
  1.2       +1 -3      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/DoubleTypeConverter.java
  
  Index: DoubleTypeConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/DoubleTypeConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DoubleTypeConverter.java	5 Dec 2003 02:45:54 -0000	1.1
  +++ DoubleTypeConverter.java	6 Dec 2003 02:21:53 -0000	1.2
  @@ -61,11 +61,9 @@
   final class DoubleTypeConverter
       extends BaseSimpleTypeConverter
   {
  -    public Object unmarshal(UnmarshalContextImpl context)
  +    protected Object getObject(UnmarshalContextImpl context)
       {
           double val = context.getDoubleValue();
  -        assert context.isEndElement();
  -        context.next();
           return new Double(val);
       }
   
  
  
  
  1.2       +6 -7      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/FloatTypeConverter.java
  
  Index: FloatTypeConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/FloatTypeConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FloatTypeConverter.java	5 Dec 2003 02:45:54 -0000	1.1
  +++ FloatTypeConverter.java	6 Dec 2003 02:21:53 -0000	1.2
  @@ -61,13 +61,6 @@
   final class FloatTypeConverter
       extends BaseSimpleTypeConverter
   {
  -    public Object unmarshal(UnmarshalContextImpl context)
  -    {
  -        float val = context.getFloatValue();
  -        assert context.isEndElement();
  -        context.next();
  -        return new Float(val);
  -    }
   
       public Object unmarshalAttribute(UnmarshalContextImpl context)
       {
  @@ -80,5 +73,11 @@
       {
           Float val = (Float)value;
           return XsTypeConverter.printFloat(val.floatValue());
  +    }
  +
  +    protected Object getObject(UnmarshalContextImpl context)
  +    {
  +        float val = context.getFloatValue();
  +        return new Float(val);
       }
   }
  
  
  
  1.2       +1 -3      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/IntTypeConverter.java
  
  Index: IntTypeConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/IntTypeConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IntTypeConverter.java	5 Dec 2003 02:45:54 -0000	1.1
  +++ IntTypeConverter.java	6 Dec 2003 02:21:53 -0000	1.2
  @@ -61,11 +61,9 @@
   final class IntTypeConverter
       extends BaseSimpleTypeConverter
   {
  -    public Object unmarshal(UnmarshalContextImpl context)
  +    protected Object getObject(UnmarshalContextImpl context)
       {
           int val = context.getIntValue();
  -        assert context.isEndElement();
  -        context.next();
           return new Integer(val);
       }
   
  
  
  
  1.2       +1 -3      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/IntegerTypeConverter.java
  
  Index: IntegerTypeConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/IntegerTypeConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IntegerTypeConverter.java	5 Dec 2003 23:48:22 -0000	1.1
  +++ IntegerTypeConverter.java	6 Dec 2003 02:21:53 -0000	1.2
  @@ -63,11 +63,9 @@
   final class IntegerTypeConverter
       extends BaseSimpleTypeConverter
   {
  -    public Object unmarshal(UnmarshalContextImpl context)
  +    protected Object getObject(UnmarshalContextImpl context)
       {
           BigInteger val = context.getBigIntegerValue();
  -        assert context.isEndElement();
  -        context.next();
           return val;
       }
   
  
  
  
  1.2       +1 -3      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/LongTypeConverter.java
  
  Index: LongTypeConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/LongTypeConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LongTypeConverter.java	5 Dec 2003 02:45:54 -0000	1.1
  +++ LongTypeConverter.java	6 Dec 2003 02:21:53 -0000	1.2
  @@ -61,11 +61,9 @@
   final class LongTypeConverter
       extends BaseSimpleTypeConverter
   {
  -    public Object unmarshal(UnmarshalContextImpl context)
  +    protected Object getObject(UnmarshalContextImpl context)
       {
           long val = context.getLongValue();
  -        assert context.isEndElement();
  -        context.next();
           return new Long(val);
       }
   
  
  
  
  1.2       +1 -3      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ShortTypeConverter.java
  
  Index: ShortTypeConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ShortTypeConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ShortTypeConverter.java	5 Dec 2003 02:45:54 -0000	1.1
  +++ ShortTypeConverter.java	6 Dec 2003 02:21:53 -0000	1.2
  @@ -61,11 +61,9 @@
   final class ShortTypeConverter
       extends BaseSimpleTypeConverter
   {
  -    public Object unmarshal(UnmarshalContextImpl context)
  +    protected Object getObject(UnmarshalContextImpl context)
       {
           short val = context.getShortValue();
  -        assert context.isEndElement();
  -        context.next();
           return new Short(val);
       }
   
  
  
  
  1.2       +1 -3      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/StringTypeConverter.java
  
  Index: StringTypeConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/StringTypeConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StringTypeConverter.java	5 Dec 2003 02:45:54 -0000	1.1
  +++ StringTypeConverter.java	6 Dec 2003 02:21:53 -0000	1.2
  @@ -61,11 +61,9 @@
   final class StringTypeConverter
       extends BaseSimpleTypeConverter
   {
  -    public Object unmarshal(UnmarshalContextImpl context)
  +    protected Object getObject(UnmarshalContextImpl context)
       {
           String val = context.getStringValue();
  -        assert context.isEndElement();
  -        context.next();
           return val;
       }
   
  
  
  
  1.6       +0 -1      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/UnmarshalContextImpl.java
  
  Index: UnmarshalContextImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/UnmarshalContextImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- UnmarshalContextImpl.java	5 Dec 2003 23:48:22 -0000	1.5
  +++ UnmarshalContextImpl.java	6 Dec 2003 02:21:53 -0000	1.6
  @@ -613,6 +613,5 @@
   
           return baseReader.getAttributeLocalName(currentAttributeIndex);
       }
  -
   }
   
  
  
  
  1.6       +1 -1      xml-xmlbeans/v2/test/cases/marshal/doc.xml
  
  Index: doc.xml
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/cases/marshal/doc.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- doc.xml	5 Dec 2003 23:48:22 -0000	1.5
  +++ doc.xml	6 Dec 2003 02:21:53 -0000	1.6
  @@ -4,7 +4,7 @@
       xmlns:My="java:com.mytest" xsi:type="My:MyClass">
   
       <My:Myelt ignore="someval" My:Attrib="4444.123456789">
  -        <My:MyFloat>65.34</My:MyFloat>
  +        <My:MyFloat>111111165.34</My:MyFloat>
           <My:MyClass>
               <My:Myatt xsi:type="xsd:token">inner-str</My:Myatt>
           </My:MyClass>
  
  
  

---------------------------------------------------------------------
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