axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/encoding ElementSerializer.java TypeMappingRegistry.java
Date Wed, 12 Dec 2001 16:37:08 GMT
rubys       01/12/12 08:37:08

  Modified:    java/src/org/apache/axis/encoding Tag: alpha-3
                        ElementSerializer.java TypeMappingRegistry.java
  Log:
  Element serializer fixes
  Submitted by:	Dug
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.2   +14 -2     xml-axis/java/src/org/apache/axis/encoding/ElementSerializer.java
  
  Index: ElementSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ElementSerializer.java,v
  retrieving revision 1.2.2.1
  retrieving revision 1.2.2.2
  diff -u -r1.2.2.1 -r1.2.2.2
  --- ElementSerializer.java	2001/12/12 00:51:07	1.2.2.1
  +++ ElementSerializer.java	2001/12/12 16:37:08	1.2.2.2
  @@ -66,6 +66,7 @@
   
   import javax.xml.rpc.namespace.QName;
   import java.io.IOException;
  +import java.util.ArrayList;
   
   /**
    * Serializer for DOM elements
  @@ -82,8 +83,10 @@
       {
           if (!(value instanceof Element))
               throw new IOException(JavaUtils.getMessage("cantSerialize01"));
  -        
  +
  +        context.startElement(name, attributes);
           context.writeDOMElement((Element)value);
  +        context.endElement();
       }
   
       // Our static deserializer factory
  @@ -99,9 +102,18 @@
                                  throws SAXException
       {
           try {
  -            value = context.getCurElement().getAsDOM();
  +            MessageElement msgElem = context.getCurElement();
  +            if ( msgElem != null ) {
  +                ArrayList children = msgElem.getChildren();
  +                if ( children != null ) {
  +                    msgElem = (MessageElement) children.get(0);
  +                    if ( msgElem != null )
  +                        value = msgElem.getAsDOM();
  +                }
  +            }
           }
           catch( Exception exp ) {
  +            exp.printStackTrace();
               throw new SAXException( exp );
           }
       }
  
  
  
  1.36.2.1  +27 -27    xml-axis/java/src/org/apache/axis/encoding/TypeMappingRegistry.java
  
  Index: TypeMappingRegistry.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/TypeMappingRegistry.java,v
  retrieving revision 1.36
  retrieving revision 1.36.2.1
  diff -u -r1.36 -r1.36.2.1
  --- TypeMappingRegistry.java	2001/11/25 23:49:33	1.36
  +++ TypeMappingRegistry.java	2001/12/12 16:37:08	1.36.2.1
  @@ -69,6 +69,7 @@
   import java.io.Serializable;
   import java.util.Enumeration;
   import java.util.Hashtable;
  +import java.util.Vector;
   
   /**
    * @author James Snell (jasnell@us.ibm.com)
  @@ -228,8 +229,7 @@
           String prefix = context.
                              getPrefixForURI(Constants.URI_CURRENT_SCHEMA_XSI,
                                              "xsi");
  -        
  -        
  +
           attrs.addAttribute(Constants.URI_CURRENT_SCHEMA_XSI,
                              "type",
                              prefix + ":type",
  @@ -242,34 +242,34 @@
           throws IOException
       {
           if (value != null) {
  -            Class _class = value.getClass();
  -            
  -            // Find a Serializer for this class, walking up the inheritance
  -            // hierarchy and implemented interfaces list.
  -            while (_class != null) {
  -                Serializer ser = getSerializer(_class);
  -                if (ser != null) {
  -                    QName type = getTypeQName(_class);
  -                    attributes = setTypeAttribute(attributes, type, context);
  -                    ser.serialize(name, attributes, value, context);
  -                    return;
  -                }
  +            Serializer  ser     = null ;
  +            Class       _class  = null ;
   
  -                Class [] ifaces = _class.getInterfaces();
  -                for (int i = 0; i < ifaces.length; i++) {
  -                    Class iface = ifaces[i];
  -                    ser = getSerializer(iface);
  -                    if (ser != null) {
  -                        QName type = getTypeQName(iface);
  -                        attributes = setTypeAttribute(attributes, type, context);
  -                        ser.serialize(name, attributes, value, context);
  -                        return;
  -                    }
  +            // Check the most common case first
  +            ser = getSerializer( _class = value.getClass() );
  +            if ( ser == null ) {
  +                Vector  classes = new Vector();
  +                classes.add( _class );
  +        
  +                while( classes.size() != 0 ) {
  +                    _class = (Class) classes.remove( 0 );
  +                    if ( (ser = getSerializer(_class)) != null ) break ;
  +                    if ( classes == null ) classes = new Vector();
  +                    Class[] ifaces = _class.getInterfaces();
  +                    for (int i = 0 ; i < ifaces.length ; i++ ) 
  +                        classes.add( ifaces[i] );
  +                    _class = _class.getSuperclass();
  +                    if ( _class != null ) classes.add( _class );
                   }
  -                
  -                _class = _class.getSuperclass();
               }
  -            
  +
  +            if ( ser != null ) {
  +                QName type = getTypeQName(_class);
  +                attributes = setTypeAttribute(attributes, type, context);
  +                ser.serialize(name, attributes, value, context);
  +                return;
  +            }
  +
               throw new IOException(JavaUtils.getMessage("noSerializer00",
                       value.getClass().getName(), "" + this));
           }
  
  
  

Mime
View raw message