axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject cvs commit: xml-axis/java/test/wsdl/types ComprehensiveTypes.wsdl
Date Tue, 25 Jun 2002 14:45:56 GMT
scheu       2002/06/25 07:45:56

  Modified:    java/src/org/apache/axis/wsdl/toJava JavaEnumTypeWriter.java
                        Utils.java
               java/test/wsdl/types ComprehensiveTypes.wsdl
  Log:
  Fix for Bugzilla Defect: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10198
  
  This fix is necessary for TCK compliance.
  
  Problem:  Enumerations of xsd:decimal and xsd:integer (BigDecimal and BigInteger)
  were not supported.
  
  Solution: Added the support and added an enumeration of xsd:integer to the
  comprehensive testcase.
  
  Revision  Changes    Path
  1.11      +42 -18    xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaEnumTypeWriter.java
  
  Index: JavaEnumTypeWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaEnumTypeWriter.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- JavaEnumTypeWriter.java	14 Jun 2002 16:11:12 -0000	1.10
  +++ JavaEnumTypeWriter.java	25 Jun 2002 14:45:56 -0000	1.11
  @@ -103,31 +103,42 @@
           // The base type could be a non-object, if so get the corresponding Class.
           String baseType = ((TypeEntry) elements.get(0)).getName();
           String baseClass = "Object";
  -        if (baseType.indexOf("String") >=0)
  +        if (baseType.indexOf("String") >=0) {
               baseClass = "String";
  -        else if (baseType.indexOf("int") == 0)
  +        } else if (baseType.equals("java.math.BigDecimal")) {
  +            baseClass = "java.math.BigDecimal";
  +        } else if (baseType.equals("java.math.BigInteger")) {
  +            baseClass = "java.math.BigInteger";
  +        } else if (baseType.indexOf("int") == 0) {
               baseClass = "Integer";
  -        else if (baseType.indexOf("char") == 0)
  +        } else if (baseType.indexOf("char") == 0) {
               baseClass = "Character";
  -        else if (baseType.indexOf("short") == 0)
  +        } else if (baseType.indexOf("short") == 0) {
               baseClass = "Short";
  -        else if (baseType.indexOf("long") == 0)
  +        } else if (baseType.indexOf("long") == 0) {
               baseClass = "Long";
  -        else if (baseType.indexOf("double") == 0)
  +        } else if (baseType.indexOf("double") == 0) {
               baseClass = "Double";
  -        else if (baseType.indexOf("float") == 0)
  +        } else if (baseType.indexOf("float") == 0) {
               baseClass = "Float";
  -        else if (baseType.indexOf("byte") == 0)
  +        }else if (baseType.indexOf("byte") == 0) {
               baseClass = "Byte";
  +        }
           
           // Create a list of the literal values.
           Vector values = new Vector();
           for (int i=1; i < elements.size(); i++) {
               String value = (String) elements.get(i);
  -            if (baseClass.equals("String"))
  +            if (baseClass.equals("String")) {
                   value = "\"" + value + "\"";  // Surround literal with double quotes
  -            else if (baseClass.equals("Character"))
  +            }
  +            if (baseClass.equals("java.math.BigDecimal") ||
  +                baseClass.equals("java.math.BigInteger")) {
  +                value = "new "+baseClass +"(\"" + value + "\")"; 
  +            }
  +            else if (baseClass.equals("Character")) {
                   value = "'" + value + "'";
  +            }
               else if (baseClass.equals("Float")) {
                   if (!value.endsWith("F") &&   // Indicate float literal so javac
                       !value.endsWith("f"))     // doesn't complain about precision.
  @@ -155,10 +166,13 @@
           pw.println("    // " + JavaUtils.getMessage("ctor00"));
           pw.println("    protected " + javaName + "(" + baseType + " value) {");
           pw.println("        _value_ = value;");
  -        if (baseClass.equals("String"))
  +        if (baseClass.equals("String") || 
  +            baseClass.equals("java.math.BigDecimal") ||
  +            baseClass.equals("java.math.BigInteger")) {
               pw.println("        _table_.put(_value_,this);");
  -        else
  +        } else {
               pw.println("        _table_.put(new " + baseClass + "(_value_),this);");
  +        }
           pw.println("    };");
           pw.println("");
   
  @@ -182,19 +196,25 @@
           pw.println("    public static " + javaName+ " fromValue(" + baseType +" value)");
           pw.println("          throws java.lang.IllegalStateException {");
           pw.println("        "+javaName+" enum = ("+javaName+")");
  -        if (baseClass.equals("String"))
  +        if (baseClass.equals("String") || 
  +            baseClass.equals("java.math.BigDecimal") ||
  +            baseClass.equals("java.math.BigInteger")) {
               pw.println("            _table_.get(value);");
  -        else
  +        } else {
               pw.println("            _table_.get(new " + baseClass + "(value));");
  +        }
           pw.println("        if (enum==null) throw new java.lang.IllegalStateException();");
           pw.println("        return enum;");
           pw.println("    }");
  -
  +        
           // FromString returns the unique enumeration value object from a string representation
           pw.println("    public static " + javaName+ " fromString(String value)");
           pw.println("          throws java.lang.IllegalStateException {");
           if (baseClass.equals("String")) {
               pw.println("        return fromValue(value);");                           
         
  +        } else if (baseClass.equals("java.math.BigDecimal") ||
  +                   baseClass.equals("java.math.BigInteger")) {
  +            pw.println("        return fromValue(new " + baseClass + "(value));");
           } else if (baseClass.equals("Character")) {
               pw.println("        if (value != null && value.length() == 1);"); 

               pw.println("            return fromValue(value.charAt(0));");             
       
  @@ -220,12 +240,16 @@
           
           // Provide a reasonable hashCode method (hashCode of the string value of the enumeration)
           pw.println("    public int hashCode() { return toString().hashCode();}");
  -
  +        
           // toString returns a string representation of the enumerated value
  -        if (baseClass.equals("String"))
  +        if (baseClass.equals("String")) {
               pw.println("    public String toString() { return _value_;}");
  -        else                            
  +        } else if (baseClass.equals("java.math.BigDecimal") ||
  +                   baseClass.equals("java.math.BigInteger")) {
  +            pw.println("    public String toString() { return _value_.toString();}");
  +        } else {                            
               pw.println("    public String toString() { return String.valueOf(_value_);}");
  +        }
       } // writeFileBody
   
       /**
  
  
  
  1.40      +2 -0      xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java
  
  Index: Utils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- Utils.java	20 Jun 2002 20:35:48 -0000	1.39
  +++ Utils.java	25 Jun 2002 14:45:56 -0000	1.40
  @@ -254,6 +254,8 @@
                   if (baseEType != null) {
                       String javaName = baseEType.getName();
                       if (javaName.equals("java.lang.String") ||
  +                        javaName.equals("java.math.BigInteger") ||
  +                        javaName.equals("java.math.BigDecimal") ||
                           javaName.equals("int") ||
                           javaName.equals("long") ||
                           javaName.equals("short") ||
  
  
  
  1.32      +8 -0      xml-axis/java/test/wsdl/types/ComprehensiveTypes.wsdl
  
  Index: ComprehensiveTypes.wsdl
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/types/ComprehensiveTypes.wsdl,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- ComprehensiveTypes.wsdl	14 Jun 2002 16:11:12 -0000	1.31
  +++ ComprehensiveTypes.wsdl	25 Jun 2002 14:45:56 -0000	1.32
  @@ -83,6 +83,7 @@
               <xsd:element name="enum5" type="typens:enumDouble"/>
               <xsd:element name="enum6" type="typens:enumShort"/>
               <xsd:element name="enum7" type="typens:enumByte"/>
  +            <xsd:element name="enum8" type="typens:enumInteger"/>
               <xsd:element name="soapint" type="soapenc:int"/>
               <xsd:element name="nested" type="typens2:b"/>
               <xsd:element name="D_TSENT" type="xsd:string"/> <!-- test strange
name -->
  @@ -261,6 +262,13 @@
           </xsd:restriction>
         </xsd:simpleType>
   
  +      <xsd:simpleType name="enumInteger">
  +        <xsd:restriction base="xsd:integer">
  +          <xsd:enumeration value="1"/>
  +          <xsd:enumeration value="2"/>                    
  +          <xsd:enumeration value="3"/>                    
  +        </xsd:restriction>
  +      </xsd:simpleType>
   
         <xsd:simpleType name="flowDirectionType">
           <xsd:restriction base="xsd:string">
  
  
  

Mime
View raw message