glyn        02/03/14 09:01:13

  Modified:    java/src/org/apache/axis/message MessageElement.java
                        SOAPHeader.java
               java/src/org/apache/axis/utils resources.properties
  Log:
  MessageElement.outputImpl serialises the object value or the children of the
  element. Policing added to setObjectValue and addChild so that no
  MessageElement may ever contain both a value and a child. setObjectValue
  made public.
  
  Based on a patch submitted by Taras Shkvarchuk.
  
  Revision  Changes    Path
  1.84      +38 -3     xml-axis/java/src/org/apache/axis/message/MessageElement.java
  
  Index: MessageElement.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/MessageElement.java,v
  retrieving revision 1.83
  retrieving revision 1.84
  diff -u -r1.83 -r1.84
  --- MessageElement.java       13 Mar 2002 15:20:03 -0000      1.83
  +++ MessageElement.java       14 Mar 2002 17:01:13 -0000      1.84
  @@ -309,9 +309,17 @@
       }
       
       private ArrayList children = null;
  -    
  +
  +    /**
  +     * Note that this method will log a error and no-op if there is
  +     * a value (set using setObjectValue) in the MessageElement.
  +     */
       public void addChild(MessageElement el)
       {
  +        if (objectValue != null) {
  +            log.error(JavaUtils.getMessage("valuePresent"));
  +            return;
  +        }
           if (children == null)
               children = new ArrayList();
           children.add(el);
  @@ -400,9 +408,16 @@
        * Sets value of this node to an Object.
        * A serializer needs to be registered for this object class for proper
        * operation.
  +     * <p>
  +     * Note that this method will log and error and no-op if there are
  +     * any children in the MessageElement.
        * @param newValue node's value or null.
        */
  -    protected void setObjectValue(Object newValue){
  +    public void setObjectValue(Object newValue){
  +        if (children != null) {
  +            log.error(JavaUtils.getMessage("childPresent"));
  +            return;
  +        }
           this.objectValue = newValue;
       }
       
  @@ -569,7 +584,9 @@
       public final void output(SerializationContext context) throws Exception
       {
           if ((recorder != null) && (!_isDirty)) {
  -            recorder.replay(startEventIndex, endEventIndex, new 
SAXOutputter(context));
  +            recorder.replay(startEventIndex,
  +                            endEventIndex,
  +                            new SAXOutputter(context));
               return;
           }
   
  @@ -622,7 +639,25 @@
           if (prefix != null)
               context.registerPrefixForURI(prefix, namespaceURI);
   
  +        if (objectValue != null) {
  +            Serializer typeSerial = context.
  +                getSerializerForJavaType(objectValue.getClass());
  +
  +            if (typeSerial != null) {
  +                typeSerial.serialize(new QName(namespaceURI, name),
  +                                     attributes,
  +                                     objectValue,
  +                                     context);
  +                return;
  +            }
  +        }
  +
           context.startElement(new QName(namespaceURI, name), attributes);
  +        if (children != null) {
  +            for (Iterator it = children.iterator(); it.hasNext();) {
  +                ((MessageElement)it.next()).output(context);
  +            }
  +        }
           context.endElement();
       }
   
  
  
  
  1.34      +0 -12     xml-axis/java/src/org/apache/axis/message/SOAPHeader.java
  
  Index: SOAPHeader.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPHeader.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- SOAPHeader.java   13 Mar 2002 15:20:03 -0000      1.33
  +++ SOAPHeader.java   14 Mar 2002 17:01:13 -0000      1.34
  @@ -139,16 +139,4 @@
       public boolean isProcessed() {
           return( processed );
       }
  -
  -    protected void outputImpl(SerializationContext context) throws Exception {
  -        Object value = getObjectValue();
  -        if (value == null) {
  -            super.outputImpl(context);
  -        } else {
  -            context.serialize(new QName(namespaceURI,name),
  -                              attributes, 
  -                              value, 
  -                              value.getClass() );
  -        }
  -    }
   }
  
  
  
  1.69      +3 -0      xml-axis/java/src/org/apache/axis/utils/resources.properties
  
  Index: resources.properties
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/resources.properties,v
  retrieving revision 1.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- resources.properties      13 Mar 2002 05:18:06 -0000      1.68
  +++ resources.properties      14 Mar 2002 17:01:13 -0000      1.69
  @@ -94,6 +94,7 @@
   cantSetURI00=Cannot set location URI:  {0}
   cantTunnel00=Unable to tunnel through {0}:{1}.  Proxy returns "{2}"
   changePwd00=Changing admin password
  +childPresent=MessageElement.setObjectValue called when a child element is present
   compiling00=Compiling:  {0}
   ctor00=Constructor
   convert00=Trying to convert {0} to {1}
  @@ -693,3 +694,5 @@
   onlyOneMapping=Only a single <elementMapping> is allowed per-operation at present.
   
   timedOut=WSDL2Java emitter timed out (this often means the WSDL at the specified 
URL is inaccessible)!
  +
  +valuePresent=MessageElement.addChild called when an object value is present
  \ No newline at end of file
  
  
  


Reply via email to