You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2004/10/14 22:28:47 UTC

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

dims        2004/10/14 13:28:47

  Modified:    java/src/org/apache/axis/encoding/ser BeanSerializer.java
               java/src/org/apache/axis/encoding SerializationContext.java
  Log:
  Fix for AXIS-1585 - npe after using SerializationContext one-arg constructor
  
  Revision  Changes    Path
  1.77      +2 -2      ws-axis/java/src/org/apache/axis/encoding/ser/BeanSerializer.java
  
  Index: BeanSerializer.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/ser/BeanSerializer.java,v
  retrieving revision 1.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- BeanSerializer.java	2 Jul 2004 13:04:52 -0000	1.76
  +++ BeanSerializer.java	14 Oct 2004 20:28:47 -0000	1.77
  @@ -103,11 +103,11 @@
           Attributes beanAttrs = getObjectAttributes(value, attributes, context);
   
           // Get the encoding style
  -        String encodingStyle = context.getMessageContext().getEncodingStyle();
  +        String encodingStyle = context.getEncodingStyle();
           boolean isEncoded = Constants.isSOAP_ENC(encodingStyle);
   
           // check whether we have and xsd:any namespace="##any" type
  -        boolean suppressElement = !context.getMessageContext().isEncoded() &&
  +        boolean suppressElement = !context.isEncoded() &&
                                     name.getNamespaceURI().equals("") &&
                                     name.getLocalPart().equals("any");
   
  
  
  
  1.92      +29 -4     ws-axis/java/src/org/apache/axis/encoding/SerializationContext.java
  
  Index: SerializationContext.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/SerializationContext.java,v
  retrieving revision 1.91
  retrieving revision 1.92
  diff -u -r1.91 -r1.92
  --- SerializationContext.java	29 Jul 2004 21:40:26 -0000	1.91
  +++ SerializationContext.java	14 Oct 2004 20:28:47 -0000	1.92
  @@ -18,6 +18,9 @@
   
   import java.io.IOException;
   import java.io.Writer;
  +import java.lang.IllegalAccessException;
  +import java.lang.NoSuchMethodException;
  +import java.lang.reflect.InvocationTargetException;
   import java.lang.reflect.Method;
   import java.util.ArrayList;
   import java.util.Calendar;
  @@ -457,6 +460,26 @@
       }
   
       /**
  +     * Returns this context's encoding style.  If we've got a message
  +     * context then we'll get the style from that; otherwise we'll
  +     * return a default.
  +     *
  +     * @return a <code>String</code> value
  +     */
  +    public String getEncodingStyle() {
  +        return msgContext == null ? Use.ENCODED.getEncoding() : msgContext.getEncodingStyle();
  +    }
  +
  +    /**
  +     * Returns whether this context should be encoded or not.
  +     *
  +     * @return a <code>boolean</code> value
  +     */
  +    public boolean isEncoded() {
  +        return msgContext == null ? true : msgContext.isEncoded();
  +    }
  +
  +    /**
        * Convert QName to a string of the form <prefix>:<localpart>
        * @param qName
        * @return prefixed qname representation for serialization.
  @@ -698,7 +721,7 @@
           // hashCode() and equals() methods have been overloaded to make two
           // Objects appear equal.
   
  -        if (doMultiRefs && (msgContext == null || msgContext.isEncoded()) &&
  +        if (doMultiRefs && isEncoded() &&
                   (value != forceSer) && !isPrimitive(value)) {
               if (multiRefIndex == -1)
                   multiRefValues = new HashMap();
  @@ -1277,9 +1300,11 @@
                       SERIALIZER_METHOD, SERIALIZER_CLASSES);
               if (method != null) {
                   serializer = (Serializer) method.invoke(null,
  -                     new Object[] {msgContext.getEncodingStyle(), javaType, qname});
  +                    new Object[] {getEncodingStyle(), javaType, qname});
               }
  -       } catch (Exception e) {
  +       } catch (NoSuchMethodException e) {
  +       } catch (IllegalAccessException e) {
  +       } catch (InvocationTargetException e) {
          }
          return serializer;
       }
  @@ -1363,7 +1388,7 @@
                       actualXMLType.value =
                           ((BaseSerializerFactory) serFactory).getXMLType();
                   }
  -                boolean encoded = (msgContext == null || msgContext.isEncoded());
  +                boolean encoded = isEncoded();
                   if (actualXMLType.value == null ||
                           (!encoded && actualXMLType.value.equals(soapConstants.getArrayType()))) {
                       actualXMLType.value = tm.getXMLType(javaType,