owenb       2003/04/01 04:45:56

  Modified:    java/src/org/apache/wsif/providers/soap/apacheaxis
                        WSDL2JavaMapper.java
               java/src/org/apache/wsif/util WSIFUtils.java
               java/src/org/apache/wsif/mapping WSIFDefaultMapper.java
  Added:       java/src/org/apache/wsif/mapping MappingHelper.java
  Log:
  Separate out utility method for populating a map with standard xml to Java mappings 
for simple types
  
  Revision  Changes    Path
  1.4       +8 -78     
xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSDL2JavaMapper.java
  
  Index: WSDL2JavaMapper.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSDL2JavaMapper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- WSDL2JavaMapper.java      5 Mar 2003 17:59:12 -0000       1.3
  +++ WSDL2JavaMapper.java      1 Apr 2003 12:45:56 -0000       1.4
  @@ -69,6 +69,7 @@
   
   import org.apache.wsif.WSIFConstants;
   import org.apache.wsif.logging.Trc;
  +import org.apache.wsif.mapping.MappingHelper;
   import org.apache.wsif.mapping.WSIFMapper;
   import org.apache.wsif.mapping.WSIFMappingConvention;
   import org.apache.wsif.schema.ComplexType;
  @@ -150,30 +151,30 @@
   
           if (includeStandardMappings) {
               // set up all standard mappings
  -            populateWithStandardMappings(
  +            MappingHelper.populateWithStandardXMLJavaMappings(
                   table,
                   WSIFConstants.NS_URI_1999_SCHEMA_XSD,
                   true);
  -            populateWithStandardMappings(
  +            MappingHelper.populateWithStandardXMLJavaMappings(
                   table,
                   WSIFConstants.NS_URI_2000_SCHEMA_XSD,
                   false);
  -            populateWithStandardMappings(
  +            MappingHelper.populateWithStandardXMLJavaMappings(
                   table,
                   WSIFConstants.NS_URI_2001_SCHEMA_XSD,
                   false);
           } else {
               // set up all standard mappings in a seperate map for use when 
resolving arrays                  
               standards = new HashMap();
  -            populateWithStandardMappings(
  +            MappingHelper.populateWithStandardXMLJavaMappings(
                   standards,
                   WSIFConstants.NS_URI_1999_SCHEMA_XSD,
                   true);
  -            populateWithStandardMappings(
  +            MappingHelper.populateWithStandardXMLJavaMappings(
                   standards,
                   WSIFConstants.NS_URI_2000_SCHEMA_XSD,
                   false);
  -            populateWithStandardMappings(
  +            MappingHelper.populateWithStandardXMLJavaMappings(
                   standards,
                   WSIFConstants.NS_URI_2001_SCHEMA_XSD,
                   false);
  @@ -419,78 +420,7 @@
           Trc.exit(table);
           return table;
       }
  -
  -    /**
  -     * Populate a map with the standard xml type -> Java class name mappings
  -     */
  -    public static void populateWithStandardMappings(
  -        Map t,
  -        String schemaURI,
  -        boolean oneTimeAdds) {
  -
  -        t.put(new QName(schemaURI, "string"), "java.lang.String");
  -        t.put(new QName(schemaURI, "integer"), "java.math.BigInteger");
  -        t.put(new QName(schemaURI, "boolean"), "boolean");
  -        t.put(new QName(schemaURI, "float"), "float");
  -        t.put(new QName(schemaURI, "double"), "double");
  -        t.put(new QName(schemaURI, "base64Binary"), "[B");
  -        t.put(new QName(schemaURI, "hexBinary"), "[B");
  -        t.put(new QName(schemaURI, "long"), "long");
  -        t.put(new QName(schemaURI, "int"), "int");
  -        t.put(new QName(schemaURI, "short"), "short");
  -        t.put(new QName(schemaURI, "decimal"), "java.math.BigDecimal");
  -        t.put(new QName(schemaURI, "byte"), "byte");
  -        t.put(new QName(schemaURI, "QName"), "javax.xml.namespace.QName");
  -
  -        // Register dateTime or timeInstant depending on schema
  -        if (schemaURI.equals(WSIFConstants.NS_URI_2001_SCHEMA_XSD)) {
  -            t.put(new QName(schemaURI, "dateTime"), "java.util.Calendar");
  -        } else {
  -            t.put(new QName(schemaURI, "timeInstant"), "java.util.Calendar");
  -        }
  -
  -        // Only add the SOAP-ENC simple types and soap collection class mappings 
once
  -        if (oneTimeAdds) {
  -            // SOAP encoding simple types
  -            t.put(
  -                new QName(WSIFConstants.NS_URI_SOAP_ENC, "string"),
  -                "java.lang.String");
  -            t.put(
  -                new QName(WSIFConstants.NS_URI_SOAP_ENC, "boolean"),
  -                "java.lang.Boolean");
  -            t.put(
  -                new QName(WSIFConstants.NS_URI_SOAP_ENC, "float"),
  -                "java.lang.Float");
  -            t.put(
  -                new QName(WSIFConstants.NS_URI_SOAP_ENC, "double"),
  -                "java.lang.Double");
  -            t.put(
  -                new QName(WSIFConstants.NS_URI_SOAP_ENC, "decimal"),
  -                "java.math.BigDecimal");
  -            t.put(
  -                new QName(WSIFConstants.NS_URI_SOAP_ENC, "int"),
  -                "java.lang.Integer");
  -            t.put(
  -                new QName(WSIFConstants.NS_URI_SOAP_ENC, "short"),
  -                "java.lang.Short");
  -            t.put(
  -                new QName(WSIFConstants.NS_URI_SOAP_ENC, "byte"),
  -                "java.lang.Byte");
  -            t.put(new QName(WSIFConstants.NS_URI_SOAP_ENC, "base64"), "[B");
  -
  -            // soap Java collection mappings
  -            t.put(
  -                new QName(WSIFConstants.NS_URI_APACHE_SOAP, "Map"),
  -                "java.util.Map");
  -            t.put(
  -                new QName(WSIFConstants.NS_URI_APACHE_SOAP, "Vector"),
  -                "java.util.Vector");
  -            t.put(
  -                new QName(WSIFConstants.NS_URI_APACHE_SOAP, "Hashtable"),
  -                "java.util.Hashtable");
  -        }
  -    }
  -  
  + 
       /**
        * Elements which are nillable and are based on xsd simple types should map to
        * the object wrapper version of the corresponding primitive type. This method
  
  
  
  1.38      +13 -4     xml-axis-wsif/java/src/org/apache/wsif/util/WSIFUtils.java
  
  Index: WSIFUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/util/WSIFUtils.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- WSIFUtils.java    26 Mar 2003 10:46:57 -0000      1.37
  +++ WSIFUtils.java    1 Apr 2003 12:45:56 -0000       1.38
  @@ -100,7 +100,7 @@
   import org.apache.wsif.format.WSIFFormatHandler;
   import org.apache.wsif.logging.MessageLogger;
   import org.apache.wsif.logging.Trc;
  -import org.apache.wsif.mapping.WSIFDefaultMapper;
  +import org.apache.wsif.mapping.MappingHelper;
   import org.apache.wsif.providers.ProviderUtils;
   import org.apache.wsif.wsdl.AuthenticatingProxyWSDLLocatorImpl;
   import org.apache.wsif.wsdl.ClosableLocator;
  @@ -819,9 +819,18 @@
       public static void createSimpleTypesMap() {
           synchronized (simpleTypesMap) {
               if (!simpleTypesMapCreated) {
  -             WSIFDefaultMapper.populateWithStandardMappings(simpleTypesMap, 
WSIFConstants.NS_URI_1999_SCHEMA_XSD, true);
  -             WSIFDefaultMapper.populateWithStandardMappings(simpleTypesMap, 
WSIFConstants.NS_URI_2000_SCHEMA_XSD, false);
  -             WSIFDefaultMapper.populateWithStandardMappings(simpleTypesMap, 
WSIFConstants.NS_URI_2001_SCHEMA_XSD, false);
  +                MappingHelper.populateWithStandardXMLJavaMappings(
  +                    simpleTypesMap,
  +                    WSIFConstants.NS_URI_1999_SCHEMA_XSD,
  +                    true);
  +                MappingHelper.populateWithStandardXMLJavaMappings(
  +                    simpleTypesMap,
  +                    WSIFConstants.NS_URI_2000_SCHEMA_XSD,
  +                    false);
  +                MappingHelper.populateWithStandardXMLJavaMappings(
  +                    simpleTypesMap,
  +                    WSIFConstants.NS_URI_2001_SCHEMA_XSD,
  +                    false);
                   simpleTypesMapCreated = true;
               }
           }
  
  
  
  1.3       +6 -78     
xml-axis-wsif/java/src/org/apache/wsif/mapping/WSIFDefaultMapper.java
  
  Index: WSIFDefaultMapper.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/mapping/WSIFDefaultMapper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WSIFDefaultMapper.java    5 Mar 2003 17:57:12 -0000       1.2
  +++ WSIFDefaultMapper.java    1 Apr 2003 12:45:56 -0000       1.3
  @@ -143,30 +143,30 @@
   
           if (includeStandardMappings) {
               // set up all standard mappings
  -            populateWithStandardMappings(
  +            MappingHelper.populateWithStandardXMLJavaMappings(
                   table,
                   WSIFConstants.NS_URI_1999_SCHEMA_XSD,
                   true);
  -            populateWithStandardMappings(
  +            MappingHelper.populateWithStandardXMLJavaMappings(
                   table,
                   WSIFConstants.NS_URI_2000_SCHEMA_XSD,
                   false);
  -            populateWithStandardMappings(
  +            MappingHelper.populateWithStandardXMLJavaMappings(
                   table,
                   WSIFConstants.NS_URI_2001_SCHEMA_XSD,
                   false);
           } else {
               // set up all standard mappings in a seperate map for use when 
resolving arrays                  
               standards = new HashMap();
  -            populateWithStandardMappings(
  +            MappingHelper.populateWithStandardXMLJavaMappings(
                   standards,
                   WSIFConstants.NS_URI_1999_SCHEMA_XSD,
                   true);
  -            populateWithStandardMappings(
  +            MappingHelper.populateWithStandardXMLJavaMappings(
                   standards,
                   WSIFConstants.NS_URI_2000_SCHEMA_XSD,
                   false);
  -            populateWithStandardMappings(
  +            MappingHelper.populateWithStandardXMLJavaMappings(
                   standards,
                   WSIFConstants.NS_URI_2001_SCHEMA_XSD,
                   false);
  @@ -362,78 +362,6 @@
                          
           Trc.exit(table);
           return table;
  -    }
  -
  -
  -    /**
  -     * Populate a map with the standard xml type -> Java class name mappings
  -     */
  -    public static void populateWithStandardMappings(
  -        Map t,
  -        String schemaURI,
  -        boolean oneTimeAdds) {
  -
  -        t.put(new QName(schemaURI, "string"), "java.lang.String");
  -        t.put(new QName(schemaURI, "integer"), "java.math.BigInteger");
  -        t.put(new QName(schemaURI, "boolean"), "boolean");
  -        t.put(new QName(schemaURI, "float"), "float");
  -        t.put(new QName(schemaURI, "double"), "double");
  -        t.put(new QName(schemaURI, "base64Binary"), "[B");
  -        t.put(new QName(schemaURI, "hexBinary"), "[B");
  -        t.put(new QName(schemaURI, "long"), "long");
  -        t.put(new QName(schemaURI, "int"), "int");
  -        t.put(new QName(schemaURI, "short"), "short");
  -        t.put(new QName(schemaURI, "decimal"), "java.math.BigDecimal");
  -        t.put(new QName(schemaURI, "byte"), "byte");
  -        t.put(new QName(schemaURI, "QName"), "javax.xml.namespace.QName");
  -
  -        // Register dateTime or timeInstant depending on schema
  -        if (schemaURI.equals(WSIFConstants.NS_URI_2001_SCHEMA_XSD)) {
  -            t.put(new QName(schemaURI, "dateTime"), "java.util.Calendar");
  -        } else {
  -            t.put(new QName(schemaURI, "timeInstant"), "java.util.Calendar");
  -        }
  -
  -        // Only add the SOAP-ENC simple types and soap collection class mappings 
once
  -        if (oneTimeAdds) {
  -            // SOAP encoding simple types
  -            t.put(
  -                new QName(WSIFConstants.NS_URI_SOAP_ENC, "string"),
  -                "java.lang.String");
  -            t.put(
  -                new QName(WSIFConstants.NS_URI_SOAP_ENC, "boolean"),
  -                "java.lang.Boolean");
  -            t.put(
  -                new QName(WSIFConstants.NS_URI_SOAP_ENC, "float"),
  -                "java.lang.Float");
  -            t.put(
  -                new QName(WSIFConstants.NS_URI_SOAP_ENC, "double"),
  -                "java.lang.Double");
  -            t.put(
  -                new QName(WSIFConstants.NS_URI_SOAP_ENC, "decimal"),
  -                "java.math.BigDecimal");
  -            t.put(
  -                new QName(WSIFConstants.NS_URI_SOAP_ENC, "int"),
  -                "java.lang.Integer");
  -            t.put(
  -                new QName(WSIFConstants.NS_URI_SOAP_ENC, "short"),
  -                "java.lang.Short");
  -            t.put(
  -                new QName(WSIFConstants.NS_URI_SOAP_ENC, "byte"),
  -                "java.lang.Byte");
  -            t.put(new QName(WSIFConstants.NS_URI_SOAP_ENC, "base64"), "[B");
  -
  -            // soap Java collection mappings
  -            t.put(
  -                new QName(WSIFConstants.NS_URI_APACHE_SOAP, "Map"),
  -                "java.util.Map");
  -            t.put(
  -                new QName(WSIFConstants.NS_URI_APACHE_SOAP, "Vector"),
  -                "java.util.Vector");
  -            t.put(
  -                new QName(WSIFConstants.NS_URI_APACHE_SOAP, "Hashtable"),
  -                "java.util.Hashtable");
  -        }
       }
     
       /**
  
  
  
  1.1                  
xml-axis-wsif/java/src/org/apache/wsif/mapping/MappingHelper.java
  
  Index: MappingHelper.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "WSIF" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, 2002, International
   * Business Machines, Inc., http://www.ibm.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.wsif.mapping;
  
  import java.util.Map;
  
  import javax.xml.namespace.QName;
  
  import org.apache.wsif.WSIFConstants;
  
  /**
   * Helper class for use by WSIFMapper implementations
   * 
   * @author Owen Burroughs <[EMAIL PROTECTED]>
   */
  public class MappingHelper {
      /**
       * Populate a map with the standard xml type -> Java class name mappings
       * @param map A map to popultate with mappings
       * @param xsdSchemaURI The xsd schema URI for xsd simple types being mapped
       * @param addNonXSDTypes Flag to indicate whether or not to include mappings
       * for SOAP-ENC simple types and Apache SOAP defined, Java collection class 
mappings
       * 
       */
      public static void populateWithStandardXMLJavaMappings(
          Map map,
          String xsdSchemaURI,
          boolean addNonXSDTypes) {
  
          map.put(new QName(xsdSchemaURI, "string"), "java.lang.String");
          map.put(new QName(xsdSchemaURI, "integer"), "java.math.BigInteger");
          map.put(new QName(xsdSchemaURI, "boolean"), "boolean");
          map.put(new QName(xsdSchemaURI, "float"), "float");
          map.put(new QName(xsdSchemaURI, "double"), "double");
          map.put(new QName(xsdSchemaURI, "base64Binary"), "[B");
          map.put(new QName(xsdSchemaURI, "hexBinary"), "[B");
          map.put(new QName(xsdSchemaURI, "long"), "long");
          map.put(new QName(xsdSchemaURI, "int"), "int");
          map.put(new QName(xsdSchemaURI, "short"), "short");
          map.put(new QName(xsdSchemaURI, "decimal"), "java.math.BigDecimal");
          map.put(new QName(xsdSchemaURI, "byte"), "byte");
          map.put(new QName(xsdSchemaURI, "QName"), "javax.xml.namespace.QName");
          map.put(new QName(xsdSchemaURI, "date"), "java.util.Calendar");        
          map.put(new QName(xsdSchemaURI, "time"), "java.util.Calendar");
          map.put(new QName(xsdSchemaURI, "unsignedInt"), "long");
          map.put(new QName(xsdSchemaURI, "unsignedShort"), "int");        
          map.put(new QName(xsdSchemaURI, "unsignedByte"), "short");        
          map.put(new QName(xsdSchemaURI, "anySimpleType"), "java.lang.String");
          map.put(new QName(xsdSchemaURI, "anyURI"), "java.lang.String");              
  
  
          // Register dateTime or timeInstant depending on schema
          if (xsdSchemaURI.equals(WSIFConstants.NS_URI_2001_SCHEMA_XSD)) {
              map.put(new QName(xsdSchemaURI, "dateTime"), "java.util.Calendar");
          } else {
              map.put(new QName(xsdSchemaURI, "timeInstant"), "java.util.Calendar");
          }
  
          // Only add the SOAP-ENC simple types and soap collection class mappings if
          // requested to do so
          if (addNonXSDTypes) {
              // SOAP encoding simple types
              map.put(
                  new QName(WSIFConstants.NS_URI_SOAP_ENC, "string"),
                  "java.lang.String");
              map.put(
                  new QName(WSIFConstants.NS_URI_SOAP_ENC, "boolean"),
                  "java.lang.Boolean");
              map.put(
                  new QName(WSIFConstants.NS_URI_SOAP_ENC, "float"),
                  "java.lang.Float");
              map.put(
                  new QName(WSIFConstants.NS_URI_SOAP_ENC, "double"),
                  "java.lang.Double");
              map.put(
                  new QName(WSIFConstants.NS_URI_SOAP_ENC, "decimal"),
                  "java.math.BigDecimal");
              map.put(
                  new QName(WSIFConstants.NS_URI_SOAP_ENC, "int"),
                  "java.lang.Integer");
              map.put(
                  new QName(WSIFConstants.NS_URI_SOAP_ENC, "short"),
                  "java.lang.Short");
              map.put(
                  new QName(WSIFConstants.NS_URI_SOAP_ENC, "byte"),
                  "java.lang.Byte");
              map.put(new QName(WSIFConstants.NS_URI_SOAP_ENC, "base64"), "[B");
  
              // soap Java collection mappings
              map.put(
                  new QName(WSIFConstants.NS_URI_APACHE_SOAP, "Map"),
                  "java.util.Map");
              map.put(
                  new QName(WSIFConstants.NS_URI_APACHE_SOAP, "Vector"),
                  "java.util.Vector");
              map.put(
                  new QName(WSIFConstants.NS_URI_APACHE_SOAP, "Hashtable"),
                  "java.util.Hashtable");
          }
      }
  }
  
  
  

Reply via email to