jochen      2005/04/28 16:57:53

  Modified:    .        status.xml
               src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg
                        GroupHandlerSG.java SimpleContentHandlerSG.java
                        HandlerSGImpl.java
               src/jaxme/org/apache/ws/jaxme/generator/types
                        ListTypeSGImpl.java UnionTypeSGImpl.java
                        BooleanSG.java AtomicTypeSGImpl.java StringSG.java
               src/jaxme/org/apache/ws/jaxme/junit BaseTestCase.java
               src/jaxme/org/apache/ws/jaxme/generator/sg/impl
                        ParsePrintSG.java EnumerationSG.java
               src/jaxme/org/apache/ws/jaxme/generator/sg SimpleTypeSG.java
               src/test/jaxb types.xsd
  Added:       src/jaxme/org/apache/ws/jaxme/junit EventsTest.java
  Log:
  Fixed that a simple types conversion from a string didn't generate a proper 
ParseConversionEvent.
  
  Revision  Changes    Path
  1.52      +4 -0      ws-jaxme/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/ws-jaxme/status.xml,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- status.xml        27 Apr 2005 06:23:26 -0000      1.51
  +++ status.xml        28 Apr 2005 23:57:52 -0000      1.52
  @@ -36,6 +36,10 @@
          </action>
        </release>
       <release version="0.4" date="Not yet published">
  +       <action dev="JW" type="fix" context="generator">
  +         A proper ParseConversionEvent is now generated, if the
  +         conversion of a simple type fails.
  +       </action>
         <action dev="NM" type="fix" context="generator">
                Fixed default value generation for primitive types. 
                See JAXME-47 in Jira.
  
  
  
  1.6       +4 -6      
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/GroupHandlerSG.java
  
  Index: GroupHandlerSG.java
  ===================================================================
  RCS file: 
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/GroupHandlerSG.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- GroupHandlerSG.java       24 Apr 2005 20:16:48 -0000      1.5
  +++ GroupHandlerSG.java       28 Apr 2005 23:57:53 -0000      1.6
  @@ -277,9 +277,9 @@
        private void handleEndElementState(JavaMethod pJm, LocalJavaField 
pElement,
                                                                           
ParticleSG pParticle) throws SAXException {
                if (pParticle.isElement()) {
  -                     ObjectSG osg = pParticle.getObjectSG();
  -                     TypeSG childType = osg.getTypeSG();
  -                     XsQName name = osg.getName();
  +                     ObjectSG oSG = pParticle.getObjectSG();
  +                     TypeSG childType = oSG.getTypeSG();
  +                     XsQName name = oSG.getName();
                        Object[] uriCondition;
                        if ("".equals(name.getNamespaceURI())) {
                                uriCondition = new Object[]{
  @@ -299,9 +299,7 @@
                        if (childType.isComplex()) {
                                type = 
childType.getComplexTypeSG().getClassContext().getXMLInterfaceName();
                        } else {
  -                             Object s = new Object[]{"(", String.class, ") 
", v};
  -                             v = new 
TypedValueImpl(childType.getSimpleTypeSG().getCastFromString(pJm, s, 
"getHandler()"),
  -                                                                        
childType.getSimpleTypeSG().getRuntimeType());
  +                             v = createSimpleTypeConversion(pJm, childType, 
v, oSG.getName().toString());
                                type = null;
                                if (isMixed) {
                                        LocalJavaField f = 
pJm.newJavaField(GroupUtil.getContentClass(group, pParticle, 
ctSG.getClassContext().getXMLInterfaceName()));
  
  
  
  1.5       +2 -3      
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/SimpleContentHandlerSG.java
  
  Index: SimpleContentHandlerSG.java
  ===================================================================
  RCS file: 
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/SimpleContentHandlerSG.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SimpleContentHandlerSG.java       8 Apr 2005 23:10:45 -0000       1.4
  +++ SimpleContentHandlerSG.java       28 Apr 2005 23:57:53 -0000      1.5
  @@ -43,9 +43,8 @@
                LocalJavaField element = result.newJavaField(elementInterface);
                element.addLine("(", elementInterface, ") result");
                SimpleContentSG scSG = ctSG.getSimpleContentSG();
  -             Object v = getParamResult();
  -             v = new Object[]{"(", String.class, ") ", v};
  -             TypedValue tv = 
scSG.getContentTypeSG().getSimpleTypeSG().getCastFromString(result, v, 
"getHandler()");
  +             TypedValue tv = createSimpleTypeConversion(result, 
scSG.getContentTypeSG(),
  +                                                                             
                   getParamResult(), scSG.getPropertySG().getXMLFieldName());
                scSG.getPropertySG().addValue(result, element, tv, null);
                return result;
        }
  
  
  
  1.3       +42 -1     
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/HandlerSGImpl.java
  
  Index: HandlerSGImpl.java
  ===================================================================
  RCS file: 
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/HandlerSGImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HandlerSGImpl.java        7 Mar 2005 20:00:28 -0000       1.2
  +++ HandlerSGImpl.java        28 Apr 2005 23:57:53 -0000      1.3
  @@ -25,12 +25,17 @@
   import org.apache.ws.jaxme.ValidationEvents;
   import org.apache.ws.jaxme.generator.sg.AttributeSG;
   import org.apache.ws.jaxme.generator.sg.ComplexTypeSG;
  +import org.apache.ws.jaxme.generator.sg.TypeSG;
  +import org.apache.ws.jaxme.generator.types.BooleanSG;
  +import org.apache.ws.jaxme.generator.types.StringSG;
   import org.apache.ws.jaxme.js.DirectAccessible;
   import org.apache.ws.jaxme.js.JavaMethod;
   import org.apache.ws.jaxme.js.JavaQName;
   import org.apache.ws.jaxme.js.JavaQNameImpl;
   import org.apache.ws.jaxme.js.JavaSource;
   import org.apache.ws.jaxme.js.LocalJavaField;
  +import org.apache.ws.jaxme.js.TypedValue;
  +import org.apache.ws.jaxme.js.impl.TypedValueImpl;
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
   
  @@ -133,7 +138,7 @@
                                
                                jm.addIf(firstInNamespace, 
JavaSource.getQuoted(attr.getName().getLocalName()), ".equals(", pLocalName, 
")");
                                firstInNamespace = false;
  -                             Object v = 
myAttributes[i].getTypeSG().getSimpleTypeSG().getCastFromString(jm, pValue, 
"getHandler()");
  +                             TypedValue v = createSimpleTypeConversion(jm, 
myAttributes[i].getTypeSG(), pValue, "@" + myAttributes[i].getName());
                                attr.getPropertySG().setValue(jm, result, v, 
null);
                                jm.addLine("return;");
                        }
  @@ -215,6 +220,42 @@
                return jm;
        }
   
  +     protected TypedValue createSimpleTypeConversion(JavaMethod pJm, TypeSG 
pType,
  +                                                                             
                        TypedValue pValue, String pName)
  +                     throws SAXException {
  +             JavaQName runtimeType = 
pType.getSimpleTypeSG().getRuntimeType();
  +             boolean causingParseConversionEvent = 
pType.getSimpleTypeSG().isCausingParseConversionEvent();
  +             LocalJavaField f = null;
  +             if (causingParseConversionEvent) {
  +                     f = pJm.newJavaField(runtimeType);
  +                     pJm.addTry();
  +             }
  +             Object s = new Object[]{"(", StringSG.STRING_TYPE, ") ", 
pValue};
  +             TypedValue result = new 
TypedValueImpl(pType.getSimpleTypeSG().getCastFromString(pJm, s, 
"getHandler()"),
  +                                                                             
           pType.getSimpleTypeSG().getRuntimeType());
  +             if (causingParseConversionEvent) {
  +                     pJm.addLine(f, " = ", result, ";");
  +                     result = f;
  +                     DirectAccessible e = pJm.addCatch(Exception.class);
  +                     pJm.addLine("getHandler().parseConversionEvent(",
  +                                             JavaSource.getQuoted("Failed to 
convert value of " + pName + ": "),
  +                                             " + ", pValue, ", ", e, ");");
  +                     Object o;
  +                     if (runtimeType.isPrimitive()) {
  +                             if (BooleanSG.BOOLEAN_TYPE.equals(runtimeType)) 
{
  +                                     o = "false";
  +                             } else {
  +                                     o = "0";
  +                             }
  +                     } else {
  +                             o = "null";
  +                     }
  +                     pJm.addLine(f, " = ", o, ";");
  +                     pJm.addEndTry();
  +             }
  +             return result;
  +     }
  +
        public void generate() throws SAXException {
                newAddAttributeMethod();
                newStartElementMethod();
  
  
  
  1.4       +4 -0      
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/types/ListTypeSGImpl.java
  
  Index: ListTypeSGImpl.java
  ===================================================================
  RCS file: 
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/types/ListTypeSGImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ListTypeSGImpl.java       8 Apr 2005 23:10:45 -0000       1.3
  +++ ListTypeSGImpl.java       28 Apr 2005 23:57:53 -0000      1.4
  @@ -194,4 +194,8 @@
       JavaQName listClass = "indexed".equals(s) ? ARRAYLIST_TYPE : 
JavaQNameImpl.getInstance(s, true);
       return new Object[]{"new ", listClass, "()"};
     }
  +
  +    public boolean isCausingParseConversionEvent(SimpleTypeSG pController) {
  +             return 
itemType.getSimpleTypeSG().isCausingParseConversionEvent();
  +     }
   }
  
  
  
  1.4       +9 -0      
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/types/UnionTypeSGImpl.java
  
  Index: UnionTypeSGImpl.java
  ===================================================================
  RCS file: 
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/types/UnionTypeSGImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- UnionTypeSGImpl.java      8 Apr 2005 23:10:45 -0000       1.3
  +++ UnionTypeSGImpl.java      28 Apr 2005 23:57:53 -0000      1.4
  @@ -156,4 +156,13 @@
     public Object getEqualsCheck(SimpleTypeSG pController, JavaMethod pMethod, 
Object pValue1, Object pValue2) throws SAXException {
       throw new IllegalStateException("Not implemented");
     }
  +
  +    public boolean isCausingParseConversionEvent(SimpleTypeSG pController) {
  +             for (int i = 0;  i < memberTypes.length;  i++) {
  +                     if 
(!memberTypes[i].getSimpleTypeSG().isCausingParseConversionEvent()) {
  +                             return false;
  +                     }
  +             }
  +             return true;
  +     }
   }
  
  
  
  1.5       +10 -2     
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/types/BooleanSG.java
  
  Index: BooleanSG.java
  ===================================================================
  RCS file: 
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/types/BooleanSG.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BooleanSG.java    27 Apr 2005 06:23:25 -0000      1.4
  +++ BooleanSG.java    28 Apr 2005 23:57:53 -0000      1.5
  @@ -32,8 +32,12 @@
    * @author <a href="mailto:[EMAIL PROTECTED]">Jochen Wiedmann</a>
    */
   public class BooleanSG extends PrimitiveTypeSG {
  -  public static final JavaQName BOOLEAN_TYPE = 
JavaQNameImpl.getInstance(boolean.class);
  -  public static final JavaQName BOOLEAN_OBJECT_TYPE = 
JavaQNameImpl.getInstance(Boolean.class);
  +     /** The primitive boolean type.
  +      */
  +     public static final JavaQName BOOLEAN_TYPE = 
JavaQNameImpl.getInstance(boolean.class);
  +     /** The object boolean type.
  +      */
  +     public static final JavaQName BOOLEAN_OBJECT_TYPE = 
JavaQNameImpl.getInstance(Boolean.class);
   
     /** <p>Creates a new instance of BooleanSG.java.</p>
      */
  @@ -60,4 +64,8 @@
                }
        }
     }
  +
  +    public boolean isCausingParseConversionEvent(SimpleTypeSG pController) {
  +             return false;
  +    }
   }
  
  
  
  1.5       +4 -0      
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/types/AtomicTypeSGImpl.java
  
  Index: AtomicTypeSGImpl.java
  ===================================================================
  RCS file: 
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/types/AtomicTypeSGImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AtomicTypeSGImpl.java     27 Apr 2005 06:23:25 -0000      1.4
  +++ AtomicTypeSGImpl.java     28 Apr 2005 23:57:53 -0000      1.5
  @@ -120,4 +120,8 @@
         throws SAXException {
       return new Object[]{pValue1, ".equals(", pValue2, ")"};
     }
  +
  +     public boolean isCausingParseConversionEvent(SimpleTypeSG pController) {
  +             return true;
  +     }
   }
  
  
  
  1.4       +89 -74    
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/types/StringSG.java
  
  Index: StringSG.java
  ===================================================================
  RCS file: 
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/types/StringSG.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StringSG.java     8 Apr 2005 23:10:45 -0000       1.3
  +++ StringSG.java     28 Apr 2005 23:57:53 -0000      1.4
  @@ -44,6 +44,8 @@
       super(pFactory, pSchema, pType);
     }
   
  +  /** The string type.
  +   */
     public final static JavaQName STRING_TYPE = 
JavaQNameImpl.getInstance(String.class);
     protected String getDatatypeName() { return "String"; }
     protected JavaQName getDatatypeType() { return STRING_TYPE; }
  @@ -74,78 +76,91 @@
       pSGlet.generate(pMethod, pValue);
     }
   
  -  public void addValidation(SimpleTypeSG pController, JavaMethod pMethod, 
DirectAccessible pValue)
  -      throws SAXException {
  -    AtomicTypeSG atomicType = pController.getAtomicType();
  -    Long length = atomicType.getLength();
  -    Long maxLength = atomicType.getMaxLength();
  -    Long minLength = atomicType.getMinLength();
  -
  -    if (minLength != null  &&  minLength.longValue() < 0) {
  -      throw new LocSAXException("Negative value for minLength detected: " + 
minLength, getLocator());
  -    }
  -    if (maxLength != null) { 
  -      if (maxLength.longValue() < 0) {
  -        throw new LocSAXException("Negative value for maxLength detected: " 
+ maxLength, getLocator());
  -      }
  -      if (minLength != null) {
  -        if (maxLength.longValue() < minLength.longValue()) {
  -          throw new LocSAXException("MaxLength value of " + maxLength + " is 
smaller than minLength value of " + minLength,
  -                                     getLocator());
  -        }
  -        if (maxLength.longValue() == minLength.longValue()) {
  -          length = maxLength;
  -        }
  -      }
  -    }
  -    if (length != null) { 
  -      if (length.longValue() < 0) {
  -        throw new LocSAXException("Negative value for length detected: " + 
length, getLocator());
  -      }
  -      if (maxLength != null) {
  -        if (maxLength.longValue() < length.longValue()) {
  -          throw new LocSAXException("MaxLength value of " + maxLength + " is 
smaller than length value of " + length,
  -                                     getLocator());
  -        }
  -        maxLength = null;  // Avoid unnecessary checks
  -      }
  -      if (minLength != null) { 
  -        if (minLength.longValue() > length.longValue()) { 
  -          throw new LocSAXException("MinLength value of " + minLength + " is 
larger than length value of " + length,
  -                                     getLocator());
  -        }
  -        minLength = null;  // Avoid unnecessary checks
  -      }
  -    }
  -
  -    if (length != null  ||  maxLength != null  ||  minLength != null) {
  -      if (pValue.isNullable()) {
  -        pMethod.addIf(pValue, " != null");
  -      }
  -      if (maxLength != null) {
  -        pMethod.addIf(pValue, ".length()", " > ", maxLength);
  -        pMethod.addThrowNew(IllegalArgumentException.class,
  -                            JavaSource.getQuoted("Length of " + maxLength + 
" characters exceeded: "),
  -                            " + ", pValue);
  -        pMethod.addEndIf();
  -      }
  -      if (minLength != null) {
  -        pMethod.addIf(pValue, ".length()", " < ", minLength);
  -        pMethod.addThrowNew(IllegalArgumentException.class,
  -                            JavaSource.getQuoted("Length of " + minLength + 
" characters exceeded: "),
  -                            " + ", pValue);
  -        pMethod.addEndIf();
  -      }
  -      if (length != null) {
  -        pMethod.addIf(pValue, ".length()", " != ", length);
  -        pMethod.addThrowNew(IllegalArgumentException.class,
  -                            JavaSource.getQuoted("Length of " + length + " 
characters not matched: "),
  -                            " + ", pValue);
  -        pMethod.addEndIf();
  -      }
  -      if (pValue.isNullable()) {
  -        pMethod.addEndIf();
  -      }
  -    }
  -  }
  +     public boolean isCausingParseConversionEvent(SimpleTypeSG pController) {
  +             final AtomicTypeSG atomicType = pController.getAtomicType();
  +             /* See addValidation(SimpleTypeSG, JavaMethod, 
DirectAccessible) for
  +              * when an exception can be thrown.
  +              */
  +             return atomicType.getLength() != null
  +                ||  atomicType.getMinLength() != null
  +                ||  atomicType.getMaxLength() != null;
  +     }
  +
  +    public void addValidation(SimpleTypeSG pController, JavaMethod pMethod, 
DirectAccessible pValue)
  +                     throws SAXException {
  +             /* If you add additional checks here, you should possibly modify
  +              * the isCausingParseConversionEvent(SimpleTypeSG) method as 
well.
  +              */
  +             final AtomicTypeSG atomicType = pController.getAtomicType();
  +             Long length = atomicType.getLength();
  +             Long maxLength = atomicType.getMaxLength();
  +             Long minLength = atomicType.getMinLength();
  +
  +             if (minLength != null  &&  minLength.longValue() < 0) {
  +                     throw new LocSAXException("Negative value for minLength 
detected: " + minLength, getLocator());
  +             }
  +             if (maxLength != null) { 
  +                     if (maxLength.longValue() < 0) {
  +                             throw new LocSAXException("Negative value for 
maxLength detected: " + maxLength, getLocator());
  +                     }
  +                     if (minLength != null) {
  +                             if (maxLength.longValue() < 
minLength.longValue()) {
  +                                     throw new LocSAXException("MaxLength 
value of " + maxLength + " is smaller than minLength value of " + minLength,
  +                                                     getLocator());
  +                             }
  +                             if (maxLength.longValue() == 
minLength.longValue()) {
  +                                     length = maxLength;
  +                             }
  +                     }
  +             }
  +             if (length != null) { 
  +                     if (length.longValue() < 0) {
  +                             throw new LocSAXException("Negative value for 
length detected: " + length, getLocator());
  +                     }
  +                     if (maxLength != null) {
  +                             if (maxLength.longValue() < length.longValue()) 
{
  +                                     throw new LocSAXException("MaxLength 
value of " + maxLength + " is smaller than length value of " + length,
  +                                                     getLocator());
  +                             }
  +                             maxLength = null;  // Avoid unnecessary checks
  +                     }
  +                     if (minLength != null) { 
  +                             if (minLength.longValue() > length.longValue()) 
{ 
  +                                     throw new LocSAXException("MinLength 
value of " + minLength + " is larger than length value of " + length,
  +                                                     getLocator());
  +                             }
  +                             minLength = null;  // Avoid unnecessary checks
  +                     }
  +             }
  +             
  +             if (length != null  ||  maxLength != null  ||  minLength != 
null) {
  +                     if (pValue.isNullable()) {
  +                             pMethod.addIf(pValue, " != null");
  +                     }
  +                     if (maxLength != null) {
  +                             pMethod.addIf(pValue, ".length()", " > ", 
maxLength);
  +                             
pMethod.addThrowNew(IllegalArgumentException.class,
  +                                             JavaSource.getQuoted("Length of 
" + maxLength + " characters exceeded: "),
  +                                             " + ", pValue);
  +                             pMethod.addEndIf();
  +                     }
  +                     if (minLength != null) {
  +                             pMethod.addIf(pValue, ".length()", " < ", 
minLength);
  +                             
pMethod.addThrowNew(IllegalArgumentException.class,
  +                                             JavaSource.getQuoted("Length of 
" + minLength + " characters exceeded: "),
  +                                             " + ", pValue);
  +                             pMethod.addEndIf();
  +                     }
  +                     if (length != null) {
  +                             pMethod.addIf(pValue, ".length()", " != ", 
length);
  +                             
pMethod.addThrowNew(IllegalArgumentException.class,
  +                                             JavaSource.getQuoted("Length of 
" + length + " characters not matched: "),
  +                                             " + ", pValue);
  +                             pMethod.addEndIf();
  +                     }
  +                     if (pValue.isNullable()) {
  +                             pMethod.addEndIf();
  +                     }
  +             }
  +     }
   }
  
  
  
  1.10      +4 -1      
ws-jaxme/src/jaxme/org/apache/ws/jaxme/junit/BaseTestCase.java
  
  Index: BaseTestCase.java
  ===================================================================
  RCS file: 
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/junit/BaseTestCase.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- BaseTestCase.java 24 Apr 2005 20:16:49 -0000      1.9
  +++ BaseTestCase.java 28 Apr 2005 23:57:53 -0000      1.10
  @@ -37,6 +37,9 @@
    * @version $Id$
    */
   public abstract class BaseTestCase extends TestCase {
  +    protected BaseTestCase() {
  +    }
  +
       protected BaseTestCase(String pName) {
        super(pName);
       }
  
  
  
  1.2       +48 -0     
ws-jaxme/src/jaxme/org/apache/ws/jaxme/junit/EventsTest.java
  
  
  
  
  1.7       +6 -19     
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ParsePrintSG.java
  
  Index: ParsePrintSG.java
  ===================================================================
  RCS file: 
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ParsePrintSG.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ParsePrintSG.java 8 Apr 2005 23:10:46 -0000       1.6
  +++ ParsePrintSG.java 28 Apr 2005 23:57:53 -0000      1.7
  @@ -13,6 +13,7 @@
   import org.apache.ws.jaxme.js.JavaSource;
   import org.apache.ws.jaxme.js.LocalJavaField;
   import org.apache.ws.jaxme.js.TypedValue;
  +import org.apache.ws.jaxme.js.impl.TypedValueImpl;
   import org.apache.ws.jaxme.xs.jaxb.JAXBJavaType;
   import org.xml.sax.SAXException;
   import org.xml.sax.SAXParseException;
  @@ -83,7 +84,6 @@
                                   Object pValue, Object pData)
               throws SAXParseException {
           JavaQName type = getType(pController);
  -        LocalJavaField f = pMethod.newJavaField(type);
           DirectAccessible value = getValue(pMethod, pValue, 
JavaQNameImpl.getInstance(String.class));
   
           String parseMethod = javaType.getParseMethod().trim();
  @@ -98,24 +98,7 @@
               addCall(pController, list, parseMethod, type);
           }
           addValues(list, value, pData);
  -        pMethod.addTry();
  -        pMethod.addLine(f, " = ", list, ";");
  -        DirectAccessible e = pMethod.addCatch(Exception.class);
  -        pMethod.addLine("getHandler().parseConversionEvent(",
  -                        JavaSource.getQuoted("Failed to parse value "),
  -                        " + ", value, " + ", JavaSource.getQuoted(": "),
  -                        " + ", e, ".getClass().getName(), ", e, ");");
  -        if (type.isPrimitive()) {
  -             if (JavaQNameImpl.BOOLEAN.equals(type)) {
  -                     pMethod.addLine(f, " = false;");
  -            } else {
  -             pMethod.addLine(f, " = 0;");
  -            }
  -        } else {
  -             pMethod.addLine(f, " = null;");
  -        }
  -        pMethod.addEndTry();
  -        return f;
  +             return new TypedValueImpl(list, type);
       }
   
       private TypedValue getPrintCall(SimpleTypeSG pController, JavaMethod 
pMethod,
  @@ -167,4 +150,8 @@
                return getPrintCall(pController, pMethod, pValue, pData);
           }
       }
  +
  +     public boolean isCausingParseConversionEvent(SimpleTypeSG pController) {
  +             return true;
  +     }
   }
  
  
  
  1.5       +4 -0      
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/EnumerationSG.java
  
  Index: EnumerationSG.java
  ===================================================================
  RCS file: 
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/EnumerationSG.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- EnumerationSG.java        8 Apr 2005 23:10:46 -0000       1.4
  +++ EnumerationSG.java        28 Apr 2005 23:57:53 -0000      1.5
  @@ -267,4 +267,8 @@
       super.generate(pController, pSource);
       getEnumClass(pController);
     }
  +
  +    public boolean isCausingParseConversionEvent(SimpleTypeSG pController) {
  +             return true;
  +    }
   }
  
  
  
  1.6       +6 -1      
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/SimpleTypeSG.java
  
  Index: SimpleTypeSG.java
  ===================================================================
  RCS file: 
/home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/SimpleTypeSG.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SimpleTypeSG.java 8 Apr 2005 23:10:45 -0000       1.5
  +++ SimpleTypeSG.java 28 Apr 2005 23:57:53 -0000      1.6
  @@ -74,6 +74,11 @@
      */
     public JavaQName getRuntimeType();
   
  +  /** Returns whether converting this type from a string can cause a
  +   * [EMAIL PROTECTED] javax.xml.bind.ParseConversionEvent}.
  +   */
  +  public boolean isCausingParseConversionEvent();
  +
     /** <p>Returns a piece of Java code converting the string 
<code>pValue</code>
      * into the runtime type. Conversion occurs at runtime, using the
      * given instance of [EMAIL PROTECTED] 
org.apache.ws.jaxme.JMUnmarshallerHandler}.</p>
  @@ -87,7 +92,7 @@
   
     /** <p>Returns a piece of Java code converting the runtime type
      * <code>pValue</code> into a string. Conversion occurs at runtime, using 
the
  -   * given instance of [EMAIL PROTECTED] 
org.apache.ws.jaxme.JMXmlSerializer.Data}.</p>
  +   * given instance of [EMAIL PROTECTED] 
org.apache.ws.jaxme.impl.JMUnmarshallerHandlerImpl}.</p>
      */
     public TypedValue getCastToString(JavaMethod pMethod, Object pValue, 
DirectAccessible pData) throws SAXException;
   
  
  
  
  1.11      +2 -0      ws-jaxme/src/test/jaxb/types.xsd
  
  Index: types.xsd
  ===================================================================
  RCS file: /home/cvs/ws-jaxme/src/test/jaxb/types.xsd,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- types.xsd 8 Apr 2005 23:10:46 -0000       1.10
  +++ types.xsd 28 Apr 2005 23:57:53 -0000      1.11
  @@ -55,6 +55,8 @@
       </xs:sequence>
     </xs:complexType>
   
  +  <xs:element name="EAllSimpleTypeAttrs" type="ex:AllSimpleTypeAttrs"/>
  +
     <xs:complexType name="AllSimpleTypeAttrs">
       <xs:annotation><xs:documentation>
         A complex type which includes the same type as attributes.
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to