axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/message RPCParam.java
Date Sat, 05 May 2001 18:23:55 GMT
gdaniels    01/05/05 11:23:55

  Modified:    java/src/org/apache/axis/encoding ArraySerializer.java
                        DeserializationContext.java
                        SOAPTypeMappingRegistry.java
               java/src/org/apache/axis/message RPCParam.java
  Log:
  Array serialization, a few debugging touches.
  
  Revision  Changes    Path
  1.2       +39 -1     xml-axis/java/src/org/apache/axis/encoding/ArraySerializer.java
  
  Index: ArraySerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ArraySerializer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ArraySerializer.java	2001/05/05 13:47:12	1.1
  +++ ArraySerializer.java	2001/05/05 18:23:55	1.2
  @@ -59,6 +59,7 @@
   import org.apache.axis.message.*;
   import org.apache.axis.utils.*;
   import org.xml.sax.*;
  +import org.xml.sax.helpers.AttributesImpl;
   import java.lang.reflect.Array;
   import java.io.IOException;
   
  @@ -194,6 +195,43 @@
                             Object value, SerializationContext context)
           throws IOException
       {
  -        throw new IOException("Can't serialize Arrays just yet...");
  +        if (value == null)
  +            throw new IOException("Can't serialize null Arrays just yet...");
  +    
  +        Class cls = value.getClass();
  +        if (!cls.isArray())
  +            throw new IOException("Can't seialize a " + cls.getName() +
  +                                  " with the ArraySerializer!");
  +        
  +        Class componentType = cls.getComponentType();
  +        QName componentQName = context.getQNameForClass(componentType);
  +        if (componentQName == null)
  +            throw new IOException("No mapped schema type for " + componentType.getName());
  +        String prefix = context.getPrefixForURI(componentQName.getNamespaceURI());
  +        String arrayType = prefix + ":" + componentQName.getLocalPart();
  +        int len = Array.getLength(value);
  +        
  +        arrayType += "[" + len + "]";
  +        
  +        Attributes attrs = attributes;
  +        
  +        if (attributes.getIndex(Constants.URI_SOAP_ENC,
  +                                Constants.ATTR_ARRAY_TYPE) == -1) {
  +            context.registerPrefixForURI("SOAP-ENC", Constants.URI_SOAP_ENC);
  +            AttributesImpl attrImpl = new AttributesImpl(attributes);
  +            attrImpl.addAttribute(Constants.URI_SOAP_ENC, 
  +                                  Constants.ATTR_ARRAY_TYPE,
  +                                  "SOAP-ENC:arrayType",
  +                                  "CDATA",
  +                                  arrayType);
  +            attrs = attrImpl;
  +        }
  +        
  +        context.startElement(name, attrs);
  +        
  +        for (int index = 0; index < len; index++)
  +            context.serialize(new QName("","item"), null, Array.get(value, index));
  +        
  +        context.endElement();
       }
   }
  
  
  
  1.9       +2 -1      xml-axis/java/src/org/apache/axis/encoding/DeserializationContext.java
  
  Index: DeserializationContext.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/DeserializationContext.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DeserializationContext.java	2001/05/05 16:48:32	1.8
  +++ DeserializationContext.java	2001/05/05 18:23:55	1.9
  @@ -200,7 +200,8 @@
       public DeserializerBase getDeserializer(QName qName)
       {
           DeserializerBase dSer = getTypeMappingRegistry().getDeserializer(qName);
  -        dSer.setDeserializationContext(this);
  +        if (dSer != null)
  +            dSer.setDeserializationContext(this);
           return dSer;
       }
   }
  
  
  
  1.7       +25 -0     xml-axis/java/src/org/apache/axis/encoding/SOAPTypeMappingRegistry.java
  
  Index: SOAPTypeMappingRegistry.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/SOAPTypeMappingRegistry.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SOAPTypeMappingRegistry.java	2001/05/05 13:47:12	1.6
  +++ SOAPTypeMappingRegistry.java	2001/05/05 18:23:55	1.7
  @@ -20,6 +20,7 @@
       public static final QName SOAP_INT = new QName(Constants.URI_SOAP_ENC, "int");
       public static final QName SOAP_LONG = new QName(Constants.URI_SOAP_ENC, "long");
       public static final QName SOAP_SHORT = new QName(Constants.URI_SOAP_ENC, "short");
  +    public static final QName SOAP_ARRAY = new QName(Constants.URI_SOAP_ENC, "Array");
       
       abstract class BasicDeser extends DeserializerBase {
           public void characters(char [] chars, int start, int end)
  @@ -79,6 +80,8 @@
       class ShortDeserializerFactory implements DeserializerFactory {
           public DeserializerBase getDeserializer() { return new ShortDeser(); }
       }
  +    
  +    private ArraySerializer arraySer = new ArraySerializer();
   
       /**
        * Alias common DeserializerFactories across the various popular schemas
  @@ -96,6 +99,26 @@
           }
       }
   
  +    public Serializer getSerializer(Class _class) {
  +        Serializer ser = super.getSerializer(_class);
  +        
  +        if ((ser == null) && (_class != null) &&
  +            (_class.isArray())) {
  +            ser = arraySer;
  +        }
  +        
  +        return ser;
  +    }
  +
  +    public QName getTypeQName(Class _class) {
  +        QName qName = super.getTypeQName(_class);
  +        if ((qName == null) && (_class != null) &&
  +            (_class.isArray())) {
  +            qName = SOAP_ARRAY;
  +        }
  +        return qName;
  +    }
  +    
       public SOAPTypeMappingRegistry() {
           SOAPEncoding se = new SOAPEncoding();
           addSerializer(java.lang.String.class, XSD_STRING, se);
  @@ -114,6 +137,8 @@
           addDeserializersFor(XSD_LONG, java.lang.Long.class, new LongDeserializerFactory());
           addDeserializersFor(XSD_SHORT, java.lang.Short.class, new ShortDeserializerFactory());
   
  +        // !!! Seems a little weird to pass a null class here...?
  +        addDeserializerFactory(SOAP_ARRAY, null, ArraySerializer.factory);
           /*
           addDeserializerFactory(SOAP_STRING, se);
           addDeserializerFactory(SOAP_BOOLEAN, se);
  
  
  
  1.13      +3 -0      xml-axis/java/src/org/apache/axis/message/RPCParam.java
  
  Index: RPCParam.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/RPCParam.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- RPCParam.java	2001/05/05 16:48:33	1.12
  +++ RPCParam.java	2001/05/05 18:23:55	1.13
  @@ -124,6 +124,9 @@
           // Look up type and return an appropriate deserializer
           if (typeQName != null) {
               deserializer = context.getDeserializer(typeQName);
  +            if (DEBUG_LOG) {
  +                System.err.println(typeQName + " maps to " + deserializer);
  +            }
               if (deserializer != null) {
                   return deserializer;
               }
  
  
  

Mime
View raw message