xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From daver...@apache.org
Subject cvs commit: xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema StscJavaizer.java
Date Sat, 17 Apr 2004 23:47:24 GMT
daveremy    2004/04/17 16:47:24

  Modified:    v2/src/binding/org/apache/xmlbeans/impl/binding/bts
                        JavaTypeName.java JaxrpcEnumType.java
               v2/src/binding/org/apache/xmlbeans/impl/binding/compile
                        EnumerationPrintHelper.java Schema2Java.java
               v2/src/typeimpl/org/apache/xmlbeans/impl/schema
                        StscJavaizer.java
  Log:
  Schema2Java fixes.
  Contributed by Radu Preotiuc.
  
  Revision  Changes    Path
  1.12      +9 -0      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/JavaTypeName.java
  
  Index: JavaTypeName.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/JavaTypeName.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- JavaTypeName.java	20 Mar 2004 21:51:34 -0000	1.11
  +++ JavaTypeName.java	17 Apr 2004 23:47:23 -0000	1.12
  @@ -160,6 +160,15 @@
     }
   
     /**
  +   * Returns the array string, peeling off the first depth levels
  +   */
  +  public String getArrayString(int depth) {
  +    if (arrayString.length() < depth * 2)
  +      return null;
  +    return arrayString.substring(2 * depth, arrayString.length());
  +  }
  +
  +  /**
      * True if this is an inner class name.
      */
     public boolean isInnerClass() {
  
  
  
  1.5       +3 -2      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/JaxrpcEnumType.java
  
  Index: JaxrpcEnumType.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/JaxrpcEnumType.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- JaxrpcEnumType.java	25 Mar 2004 22:00:28 -0000	1.4
  +++ JaxrpcEnumType.java	17 Apr 2004 23:47:23 -0000	1.5
  @@ -37,8 +37,9 @@
       // Constants
   
       public final static MethodName DEFAULT_GET_VALUE = MethodName.create("getValue");
  -    public final static MethodName DEFAULT_FROM_VALUE = MethodName.create("fromValue");
  -    public final static MethodName DEFAULT_FROM_STRING = MethodName.create("fromString");
  +    public final static String     DEFAULT_FROM_VALUE_NAME = "fromValue";
  +    public final static MethodName DEFAULT_FROM_STRING = MethodName.create("fromString",
  +        JavaTypeName.forString("java.lang.String"));
       public final static MethodName DEFAULT_TO_XML = MethodName.create("toXML");
   
       // ========================================================================
  
  
  
  1.3       +39 -7     xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/EnumerationPrintHelper.java
  
  Index: EnumerationPrintHelper.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/EnumerationPrintHelper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EnumerationPrintHelper.java	25 Mar 2004 22:00:28 -0000	1.2
  +++ EnumerationPrintHelper.java	17 Apr 2004 23:47:23 -0000	1.3
  @@ -29,6 +29,9 @@
   import org.apache.xmlbeans.XmlLong;
   import org.apache.xmlbeans.XmlQName;
   import org.apache.xmlbeans.XmlShort;
  +import org.apache.xmlbeans.XmlUnsignedByte;
  +import org.apache.xmlbeans.XmlUnsignedInt;
  +import org.apache.xmlbeans.XmlUnsignedShort;
   import org.apache.xmlbeans.impl.binding.bts.JavaTypeName;
   import org.apache.xmlbeans.impl.binding.joust.Expression;
   import org.apache.xmlbeans.impl.binding.joust.ExpressionFactory;
  @@ -241,7 +244,7 @@
                   qName.getPrefix() + "\")");
           break;
         case T_URI:
  -        result = mExprFactory.createVerbatim("new java.net.URI(\"" + value.getStringValue()
+ "\")");
  +        result = mExprFactory.createVerbatim("java.net.URI.create(\"" + value.getStringValue()
+ "\")");
           break;
         case T_FLOAT_CLASS:
           result = mExprFactory.createVerbatim("new Float(" + ((XmlFloat) value).getFloatValue()
+ ")");
  @@ -271,19 +274,48 @@
           result = mExprFactory.createVerbatim(String.valueOf(((XmlByte) value).getByteValue()));
           break;
         case T_FLOAT:
  -        result = mExprFactory.createVerbatim("(float)" + String.valueOf(((XmlFloat) value).getFloatValue()));
  +        {
  +          float floatValue = ((XmlFloat) value).getFloatValue();
  +          if (floatValue == Float.POSITIVE_INFINITY)
  +            result = mExprFactory.createVerbatim("Float.POSITIVE_INFINITY");
  +          else if (floatValue == Float.NEGATIVE_INFINITY)
  +            result = mExprFactory.createVerbatim("Float.NEGATIVE_INFINITY");
  +          else if (Float.isNaN(floatValue))
  +            result = mExprFactory.createVerbatim("Float.NaN");
  +          else
  +            result = mExprFactory.createVerbatim("(float)" + String.valueOf(floatValue));
  +        }
           break;
         case T_DOUBLE:
  -        result = mExprFactory.createVerbatim(String.valueOf(((XmlDouble) value).getDoubleValue()));
  +        {
  +          double doubleValue = ((XmlDouble) value).getDoubleValue();
  +          if (doubleValue == Double.POSITIVE_INFINITY)
  +            result = mExprFactory.createVerbatim("Double.POSITIVE_INFINITY");
  +          else if (doubleValue == Double.NEGATIVE_INFINITY)
  +            result = mExprFactory.createVerbatim("Double.NEGATIVE_INFINITY");
  +          else if (Double.isNaN(doubleValue))
  +            result = mExprFactory.createVerbatim("Double.NaN");
  +          else
  +            result = mExprFactory.createVerbatim(String.valueOf(doubleValue));
  +        }
           break;
         case T_LONG:
  -        result = mExprFactory.createVerbatim(String.valueOf(((XmlLong) value).getLongValue()));
  +        if (value instanceof XmlUnsignedInt)
  +          result = mExprFactory.createVerbatim(String.valueOf(((XmlUnsignedInt) value).getLongValue()));
  +        else
  +          result = mExprFactory.createVerbatim(String.valueOf(((XmlLong) value).getLongValue()));
           break;
         case T_INT:
  -        result = mExprFactory.createVerbatim(String.valueOf(((XmlInt) value).getIntValue()));
  +        if (value instanceof XmlUnsignedShort)
  +          result = mExprFactory.createVerbatim(String.valueOf(((XmlUnsignedShort) value).getIntValue()));
  +        else
  +          result = mExprFactory.createVerbatim(String.valueOf(((XmlInt) value).getIntValue()));
           break;
         case T_SHORT:
  -        result = mExprFactory.createVerbatim(String.valueOf(((XmlShort) value).getShortValue()));
  +        if (value instanceof XmlUnsignedByte)
  +          result = mExprFactory.createVerbatim(String.valueOf(((XmlUnsignedByte) value).getShortValue()));
  +        else
  +          result = mExprFactory.createVerbatim(String.valueOf(((XmlShort) value).getShortValue()));
           break;
         case T_BYTE_ARRAY:
           {
  @@ -543,7 +575,7 @@
         result = mExprFactory.createVerbatim("Float.floatToIntBits(" + var + ")");
         break;
         case T_DOUBLE:
  -      result = mExprFactory.createVerbatim("(int) (Double.doubleToLongBits(" + var + ")
^ (Double.doubleYoLongBits(" + var + ") >>> 32))");
  +      result = mExprFactory.createVerbatim("(int) (Double.doubleToLongBits(" + var + ")
^ (Double.doubleToLongBits(" + var + ") >>> 32))");
         break;
         case T_LONG:
         result = mExprFactory.createVerbatim("(int) (" + var + " ^ (" + var + " >>>
32))");
  
  
  
  1.25      +9 -6      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/Schema2Java.java
  
  Index: Schema2Java.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/Schema2Java.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- Schema2Java.java	10 Apr 2004 02:50:01 -0000	1.24
  +++ Schema2Java.java	17 Apr 2004 23:47:23 -0000	1.25
  @@ -508,7 +508,8 @@
         case Scratch.ENUM_TYPE:
           JaxrpcEnumType enumResult = new JaxrpcEnumType(btName);
           enumResult.setGetValueMethod(JaxrpcEnumType.DEFAULT_GET_VALUE);
  -        enumResult.setFromValueMethod(JaxrpcEnumType.DEFAULT_FROM_VALUE);
  +        enumResult.setFromValueMethod(MethodName.create(JaxrpcEnumType.DEFAULT_FROM_VALUE_NAME,
  +                scratch.getJavaName()));
           enumResult.setFromStringMethod(JaxrpcEnumType.DEFAULT_FROM_STRING);
           enumResult.setToXMLMethod(JaxrpcEnumType.DEFAULT_TO_XML);
           scratch.setBindingType(enumResult);
  @@ -691,15 +692,15 @@
           prop = new QNameProperty();
           prop.setQName(props[i].getName());
           prop.setAttribute(props[i].isAttribute());
  -        prop.setSetterName(MethodName.create("set" + propName,
  -                                             bType.getName().getJavaName()));
  -        prop.setGetterName(MethodName.create("get" + propName));
           prop.setNillable(props[i].hasNillable() != SchemaProperty.NEVER);
           prop.setOptional(isOptional(props[i]));
           prop.setMultiple(isMultiple);
           if (prop.isNillable() || prop.isOptional())
             bType = findBoxedType(bType);
           prop.setBindingType(bType);
  +        prop.setSetterName(MethodName.create("set" + propName,
  +                                             bType.getName().getJavaName()));
  +        prop.setGetterName(MethodName.create("get" + propName));
           if (prop.isMultiple())
                   collection = JavaTypeName.forArray(bType.getName().getJavaName(), 1);
           prop.setCollectionClass(collection);
  @@ -1799,9 +1800,11 @@
         // of the enumeration's type and then call fromValue()
         final String STRING_PARTS = "parts";
         final String BASETYPE_ARRAY = "array";
  -      mJoust.writeStatement("String[] " + STRING_PARTS + "= org.apache.xmlbeans.impl.values.XmlListImpl.split_list(value)");
  +      mJoust.writeStatement("String[] " + STRING_PARTS +
  +        "= org.apache.xmlbeans.impl.values.XmlListImpl.split_list(value)");
         mJoust.writeStatement(baseType.toString() + " " + BASETYPE_ARRAY + " = new " +
  -        baseType.getArrayItemType(1).toString() + "[" + STRING_PARTS + ".length" + "]");
  +        baseType.getArrayItemType(baseType.getArrayDepth()).toString() +
  +        "[" + STRING_PARTS + ".length" + "]" + baseType.getArrayString(1));
         mJoust.writeStatement("for (int i = 0; i < " + BASETYPE_ARRAY + ".length; i++)
" +
           BASETYPE_ARRAY + "[i] = " +
           enumHelper.getFromStringExpr(mJoust.getExpressionFactory().createVerbatim(
  
  
  
  1.5       +14 -0     xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/StscJavaizer.java
  
  Index: StscJavaizer.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/StscJavaizer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StscJavaizer.java	8 Apr 2004 19:22:03 -0000	1.4
  +++ StscJavaizer.java	17 Apr 2004 23:47:24 -0000	1.5
  @@ -421,8 +421,22 @@
       {
           StscState state = StscState.get();
   
  +        // We have to special case the document types. The reason is that a
  +        // document type can inherit from another document type without
  +        // containing all of the base type's properties (which is impossible
  +        // for normal types)
  +        if (baseType.isDocumentType() && !doInherited)
  +        {
  +            SchemaProperty s = baseType.getElementProperties()[0];
  +            usedNames.add(s.getJavaPropertyName());
  +        }
  +
           // two passes: first deal with inherited properties, then with new ones.
           // this ensures that we match up with base class definitions cleanly
  +        // BUGBUG(radup) We have to look for particles that have been removed
  +        // in the derivation tree for this type using derivation by restriction,
  +        // because they have not been removed in Java and may collide with 
  +        // this type's properties.
   
           for (int i = 0; i < props.length; i++)
           {
  
  
  

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