You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2004/06/16 21:41:20 UTC

cvs commit: ws-axis/java/src/org/apache/axis/encoding DefaultTypeMappingImpl.java

dims        2004/06/16 12:41:20

  Modified:    java/src/org/apache/axis/encoding/ser BeanDeserializer.java
                        DateDeserializer.java DateSerializer.java
               java/src/org/apache/axis/encoding
                        DefaultTypeMappingImpl.java
  Log:
  Added typemappings from JAX-RPC 1.1 for AXIS-1120 (but currently disabled by a boolean flag)
  
  Revision  Changes    Path
  1.66      +12 -4     ws-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java
  
  Index: BeanDeserializer.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java,v
  retrieving revision 1.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- BeanDeserializer.java	24 Mar 2004 19:44:58 -0000	1.65
  +++ BeanDeserializer.java	16 Jun 2004 19:41:20 -0000	1.66
  @@ -166,10 +166,6 @@
           }  
           prevQName = elemQName;
   
  -        // Fastpath nil checks...
  -        if (context.isNil(attributes))
  -            return null;
  -        
           if (typeDesc != null) {       
               // Lookup the name appropriately (assuming an unqualified
               // name for SOAP encoding, using the namespace otherwise)
  @@ -253,6 +249,18 @@
           if (dSer == null) {
               dSer = context.getDeserializerForClass(propDesc.getType());
           }
  +
  +        // Fastpath nil checks...
  +        if (context.isNil(attributes)) {
  +            if (propDesc != null && propDesc.isIndexed()) { 
  +                if (!((dSer != null) && (dSer instanceof ArrayDeserializer)) ||
  +                        propDesc.getType().isArray()) {
  +                    collectionIndex++;
  +                }
  +            }
  +            return null;
  +        }            
  +          
           if (dSer == null) {
               throw new SAXException(Messages.getMessage("noDeser00",
                                                          childXMLType.toString()));
  
  
  
  1.12      +7 -3      ws-axis/java/src/org/apache/axis/encoding/ser/DateDeserializer.java
  
  Index: DateDeserializer.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/ser/DateDeserializer.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DateDeserializer.java	25 Feb 2004 14:02:37 -0000	1.11
  +++ DateDeserializer.java	16 Jun 2004 19:41:20 -0000	1.12
  @@ -51,7 +51,7 @@
        * We just need to override makeValue().
        */
       public Object makeValue(String source) { 
  -        Date result;
  +        Object result;
           boolean bc = false;
           
           // validate fixed portion of format
  @@ -85,9 +85,13 @@
               
               // support dates before the Christian era
               if (bc) {
  -                calendar.setTime(result);
  +                calendar.setTime((Date)result);
                   calendar.set(Calendar.ERA, GregorianCalendar.BC);
  -                result = calendar.getTime();
  +                if(javaType == Date.class) {
  +                    result = calendar.getTime();
  +                } else {
  +                    result = calendar;
  +                }
               }
           }
   
  
  
  
  1.11      +3 -1      ws-axis/java/src/org/apache/axis/encoding/ser/DateSerializer.java
  
  Index: DateSerializer.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/ser/DateSerializer.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DateSerializer.java	25 Feb 2004 14:02:37 -0000	1.10
  +++ DateSerializer.java	16 Jun 2004 19:41:20 -0000	1.11
  @@ -59,7 +59,9 @@
       public String getValueAsString(Object value, SerializationContext context) {
           StringBuffer buf = new StringBuffer();
           synchronized (calendar) {
  -            calendar.setTime((Date)value);
  +            if(value instanceof Calendar) {
  +                value = ((Calendar)value).getTime();
  +            } 
               if (calendar.get(Calendar.ERA) == GregorianCalendar.BC) {
                   buf.append("-");
                   calendar.setTime((Date)value);
  
  
  
  1.77      +53 -8     ws-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java
  
  Index: DefaultTypeMappingImpl.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java,v
  retrieving revision 1.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- DefaultTypeMappingImpl.java	25 Feb 2004 14:02:35 -0000	1.76
  +++ DefaultTypeMappingImpl.java	16 Jun 2004 19:41:20 -0000	1.77
  @@ -75,7 +75,7 @@
   public class DefaultTypeMappingImpl extends TypeMappingImpl {
   
       private static DefaultTypeMappingImpl tm = null;
  -    private boolean doneInit = false;   // have we completed initalization
  +    private boolean jaxrpc11Compliance = false;
   
       /**
        * Obtain the singleton default typemapping.
  @@ -551,6 +551,58 @@
                                                Constants.XSD_SCHEMA)
           );
           
  +        if(jaxrpc11Compliance) {
  +            // Table 4-1 of the JAXRPC 1.1 spec
  +            myRegisterSimple(Constants.XSD_UNSIGNEDINT, long.class);    
  +            myRegisterSimple(Constants.XSD_UNSIGNEDSHORT, int.class);    
  +            myRegisterSimple(Constants.XSD_UNSIGNEDBYTE, short.class);   
  +            myRegister(Constants.XSD_DATETIME,       java.util.Calendar.class,
  +                       new DateSerializerFactory(java.util.Calendar.class,
  +                                                 Constants.XSD_DATE),
  +                       new DateDeserializerFactory(java.util.Calendar.class,
  +                                                   Constants.XSD_DATE)
  +            );
  +            myRegister(Constants.XSD_DATE,       java.util.Calendar.class,
  +                       new DateSerializerFactory(java.util.Calendar.class,
  +                                                 Constants.XSD_DATE),
  +                       new DateDeserializerFactory(java.util.Calendar.class,
  +                                                   Constants.XSD_DATE)
  +            );
  +            myRegister(Constants.XSD_TIME,       java.util.Calendar.class,
  +                       new DateSerializerFactory(java.util.Calendar.class,
  +                                                 Constants.XSD_TIME),
  +                       new DateDeserializerFactory(java.util.Calendar.class,
  +                                                   Constants.XSD_TIME)
  +            );
  +            try {
  +                myRegisterSimple(Constants.XSD_ANYURI, Class.forName("java.net.URI"));
  +            } 
  +            catch (ClassNotFoundException e) {
  +                myRegisterSimple(Constants.XSD_ANYURI, java.lang.String.class);
  +            }
  +            
  +            // Table 4-2 of JAXRPC 1.1 spec
  +            myRegisterSimple(Constants.XSD_DURATION, java.lang.String.class);
  +            myRegisterSimple(Constants.XSD_YEARMONTH, java.lang.String.class);
  +            myRegisterSimple(Constants.XSD_YEAR, java.lang.String.class);
  +            myRegisterSimple(Constants.XSD_MONTHDAY, java.lang.String.class);
  +            myRegisterSimple(Constants.XSD_DAY, java.lang.String.class);
  +            myRegisterSimple(Constants.XSD_MONTH, java.lang.String.class);
  +            myRegisterSimple(Constants.XSD_NORMALIZEDSTRING, java.lang.String.class);
  +            myRegisterSimple(Constants.XSD_TOKEN, java.lang.String.class);
  +            myRegisterSimple(Constants.XSD_LANGUAGE, java.lang.String.class);
  +            myRegisterSimple(Constants.XSD_NAME, java.lang.String.class);
  +            myRegisterSimple(Constants.XSD_NCNAME, java.lang.String.class);
  +            myRegisterSimple(Constants.XSD_ID, java.lang.String.class);
  +            myRegisterSimple(Constants.XSD_NMTOKEN, java.lang.String.class);
  +            myRegisterSimple(Constants.XSD_NMTOKENS, java.lang.String.class);
  +            myRegisterSimple(Constants.XSD_NONPOSITIVEINTEGER, java.math.BigInteger.class);
  +            myRegisterSimple(Constants.XSD_NEGATIVEINTEGER, java.math.BigInteger.class);
  +            myRegisterSimple(Constants.XSD_NONNEGATIVEINTEGER, java.math.BigInteger.class);
  +            myRegisterSimple(Constants.XSD_UNSIGNEDLONG, java.math.BigInteger.class);
  +            myRegisterSimple(Constants.XSD_POSITIVEINTEGER, java.math.BigInteger.class);
  +        }
  +        
           // TODO: move it to the DefaultSOAPEncodingTypeMappingImpl class
           myRegister(Constants.SOAP_ARRAY12,     java.util.Collection.class,
                      new ArraySerializerFactory(),
  @@ -595,8 +647,6 @@
           SchemaVersion.SCHEMA_1999.registerSchemaSpecificTypes(this);
           SchemaVersion.SCHEMA_2000.registerSchemaSpecificTypes(this);
           SchemaVersion.SCHEMA_2001.registerSchemaSpecificTypes(this);
  -
  -        doneInit = true;
       }
   
       /**
  @@ -662,11 +712,6 @@
   
           // Don't allow anyone but init to modify us.
           super.register(javaType, xmlType, sf, dsf);
  -//        if (doneInit && !doAutoTypes) {
  -//            throw new JAXRPCException(Messages.getMessage("fixedTypeMapping"));
  -//        }
  -//        else {
  -//        }
       }
       public void removeSerializer(Class javaType, QName xmlType)
           throws JAXRPCException {