You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@xml.apache.org by gd...@locus.apache.org on 2000/09/05 05:43:09 UTC

cvs commit: xml-soap/java/src/org/apache/soap/encoding/soapenc VectorSerializer.java

gdaniels    00/09/04 20:43:08

  Modified:    java/src/org/apache/soap/encoding/soapenc
                        VectorSerializer.java
  Log:
  Change to produce a soap structure instead of an Array.  The main reason
  for switching this is that there are times when you really want a Vector on
  the receiving side, and until there's a way to configure individual SOAP
  arrays in a schema to become Vectors, it's easier to keep them separate.
  
  See SOAPMappingRegistry for the rest of this change.
  
  Revision  Changes    Path
  1.3       +32 -14    xml-soap/java/src/org/apache/soap/encoding/soapenc/VectorSerializer.java
  
  Index: VectorSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/encoding/soapenc/VectorSerializer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- VectorSerializer.java	2000/09/01 03:52:47	1.2
  +++ VectorSerializer.java	2000/09/05 03:43:07	1.3
  @@ -111,32 +111,24 @@
                          : "";
           }
   
  -    // Since a Vector can hold objects....
  -    Class componentType = Object.class;
  -    QName elementType = xjmr.queryElementType(componentType,
  -                                              Constants.NS_URI_SOAP_ENC);
   
       if (src == null)
       {
  -      SoapEncUtils.generateNullArray(inScopeEncStyle,
  +      SoapEncUtils.generateNullStructure(inScopeEncStyle,
                                        javaType,
                                        context,
                                        sink,
                                        nsStack,
  -                                     xjmr,
  -                                     elementType,
  -                                     lengthStr);
  +                                     xjmr);
       }
       else
       {
  -      SoapEncUtils.generateArrayHeader(inScopeEncStyle,
  +      SoapEncUtils.generateStructureHeader(inScopeEncStyle,
                                          javaType,
                                          context,
                                          sink,
                                          nsStack,
  -                                       xjmr,
  -                                       elementType,
  -                                       lengthStr);
  +                                       xjmr);
   
         sink.write(StringUtils.lineSeparator);
   
  @@ -148,7 +140,7 @@
   
           if (value == null)
           {
  -          SoapEncUtils.generateNullStructure(inScopeEncStyle, componentType,
  +          SoapEncUtils.generateNullStructure(inScopeEncStyle, Object.class,
                                                "item", sink, nsStack, xjmr);
           }
           else
  @@ -173,7 +165,33 @@
                            XMLJavaMappingRegistry xjmr)
       throws IllegalArgumentException
     {
  -          throw new IllegalArgumentException("VectorSerializer used for deserialization");
  +	  Element root = (Element)src;
  +	  if (SoapEncUtils.isNull(root)) {
  +		  return new Bean(Vector.class, null);
  +	  }
  +	  
  +	  Vector v = new Vector();
  +	  
  +	  Element tempEl = DOMUtils.getFirstChildElement(root);
  +	  while (tempEl != null) {
  +		  String declEncStyle = DOMUtils.getAttributeNS(tempEl,
  +														Constants.NS_URI_SOAP_ENV, Constants.ATTR_ENCODING_STYLE);
  +		  String actualEncStyle = declEncStyle != null
  +								  ? declEncStyle
  +									: inScopeEncStyle;
  +		  QName declItemType = SoapEncUtils.getAttributeValue(tempEl,
  +															  Constants.NS_URI_SCHEMA_XSI, Constants.ATTR_TYPE, "Vector item",
  +															  false);
  +		  QName actualItemType = declItemType;
  +
  +		  Bean itemBean = xjmr.unmarshall(actualEncStyle, actualItemType, tempEl);
  +
  +		  v.addElement(itemBean.value);
  +
  +		  tempEl = DOMUtils.getNextSiblingElement(tempEl);
  +	  }
  +	  
  +	  return new Bean(Vector.class, v);
     }
   
   }