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 sc...@apache.org on 2002/01/26 03:40:36 UTC

cvs commit: xml-axis/java/src/org/apache/axis/encoding/ser ArrayDeserializer.java ArrayDeserializerFactory.java ArraySerializer.java ArraySerializerFactory.java Base64Deserializer.java Base64DeserializerFactory.java Base64Serializer.java Base64SerializerFactory.java BaseDeserializerFactory.java BaseSerializerFactory.java BeanDeserializer.java BeanDeserializerFactory.java BeanPropertyDescriptor.java BeanPropertyTarget.java BeanSerializer.java BeanSerializerFactory.java DateDeserializer.java DateDeserializerFactory.java DateSerializer.java DateSerializerFactory.java ElementDeserializer.java ElementDeserializerFactory.java ElementSerializer.java ElementSerializerFactory.java EnumDeserializer.java EnumDeserializerFactory.java EnumSerializer.java EnumSerializerFactory.java HexDeserializer.java HexDeserializerFactory.java HexSerializer.java HexSerializerFactory.java JAFDataHandlerDeserializer.java JAFDataHandlerDeserializerFactory.java JAFDataHandlerSerializer.java JAFDataHandlerSerializerFactory.java MapDeserializer.java MapDeserializerFactory.java MapSerializer.java MapSerializerFactory.java SimpleDeserializer.java SimpleDeserializerFactory.java SimpleNonPrimitiveSerializerFactory.java SimplePrimitiveSerializerFactory.java SimpleSerializer.java VectorDeserializer.java VectorDeserializerFactory.java

scheu       02/01/25 18:40:36

  Modified:    java/src/org/apache/axis/encoding
                        DeserializationContext.java Deserializer.java
                        DeserializerFactory.java SerializationContext.java
                        Serializer.java ServiceDescription.java
                        TypeMappingRegistry.java XMLType.java
  Added:       java/src/org/apache/axis/encoding Callback.java
                        CallbackTarget.java DefaultTypeMappingImpl.java
                        DeserializationContextImpl.java
                        DeserializerImpl.java DeserializerTarget.java
                        FieldTarget.java MethodTarget.java
                        SerializationContextImpl.java
                        SerializerFactory.java Target.java TypeMapping.java
                        TypeMappingImpl.java TypeMappingRegistryImpl.java
               java/src/org/apache/axis/encoding/ser ArrayDeserializer.java
                        ArrayDeserializerFactory.java ArraySerializer.java
                        ArraySerializerFactory.java Base64Deserializer.java
                        Base64DeserializerFactory.java
                        Base64Serializer.java Base64SerializerFactory.java
                        BaseDeserializerFactory.java
                        BaseSerializerFactory.java BeanDeserializer.java
                        BeanDeserializerFactory.java
                        BeanPropertyDescriptor.java BeanPropertyTarget.java
                        BeanSerializer.java BeanSerializerFactory.java
                        DateDeserializer.java DateDeserializerFactory.java
                        DateSerializer.java DateSerializerFactory.java
                        ElementDeserializer.java
                        ElementDeserializerFactory.java
                        ElementSerializer.java
                        ElementSerializerFactory.java EnumDeserializer.java
                        EnumDeserializerFactory.java EnumSerializer.java
                        EnumSerializerFactory.java HexDeserializer.java
                        HexDeserializerFactory.java HexSerializer.java
                        HexSerializerFactory.java
                        JAFDataHandlerDeserializer.java
                        JAFDataHandlerDeserializerFactory.java
                        JAFDataHandlerSerializer.java
                        JAFDataHandlerSerializerFactory.java
                        MapDeserializer.java MapDeserializerFactory.java
                        MapSerializer.java MapSerializerFactory.java
                        SimpleDeserializer.java
                        SimpleDeserializerFactory.java
                        SimpleNonPrimitiveSerializerFactory.java
                        SimplePrimitiveSerializerFactory.java
                        SimpleSerializer.java VectorDeserializer.java
                        VectorDeserializerFactory.java
  Removed:     java/src/org/apache/axis/encoding ArraySerializer.java
                        Base64Serializer.java BasicDeserializer.java
                        BeanSerializer.java BooleanDeserializerFactory.java
                        DateSerializer.java ElementSerializer.java
                        EnumSerializer.java FloatSerializer.java
                        HexSerializer.java JAFDataHandlerDeserializer.java
                        JAFDataHandlerSerializer.java MapSerializer.java
                        SOAPEncoding.java SOAPTypeMappingRegistry.java
                        ValueReceiver.java VectorDeserializer.java
  Log:
  (more commits to follow)
  
  All of these changes passed all-tests and functional-tests
  prior to committing the code.
  
  Summary of changes
  ------------------
  
  1) Added interfaces for all of the framework pieces
     (SerializationContext, DeserializationContext,
      Serializer, SerializerFactory, Deserializer,
      DeserializerFactory, TypeMappingRegistry,
      TypeMapping)
  
  2) Each of the interfaces has a corresponding
     *Impl file that contains the implementation.
     In general, I hid public fields to force
     communication through methods.
  
  3) The TypeMappingRegistry/TypeMapping code now
     conforms with the JAX-RPC spec.  Miscellaneous
     function has been removed from the classes.
     The type mapping code that was in the TypeMappingRegistry
     is now in the TypeMapping class.
  
  4) The WSDD now operates on the new TypeMapping
     code per JAX-RPC.
  
  5) The DefaultTypeMappingImpl class contains the
     SOAP/XSD mappings.  Most of this code is now
     HashMap driven.
  
  6) The new org.apache.axis.encoding.ser class
     now contains the serializer/deserializer/factory
     classes.  These classes have been exploded into
     individual classes.  See the description
     in the interface classes for more details.
  
  7) The QName constants in SOAPEncoding have been
     moved to Constants.java (i.e. XSD_INT).  This
     makes sense since the URI namespace constants
     are in Constants.java.
  
  8) The serialization framework is now passed the
     original type of the value requiring serialization.
     Thus the code now distinguishes between a java.lang.Integer
     value that was originally an int versus a java.lang.Integer.
     This distinction is necessary to discern between
     xsd:int and soapenc:int, and also affects multi-ref processing.
  
  9) Added numerous javadoc comments to the interfaces and
     added javadoc comments to all methods that were touched.
  
  10) The code, wsdd, etc. now exclusively uses factories to
      construct serializers/deserializers per JAX-RPC.  See
      the interface comments to see how such instances are constructed.
  
  11) In general the "addSerializer" and "addDeserializer" methods
      have been removed from the engine, service, etc.  Instead
      the serializer/deserializer factories are added in a compliant manner.
      I changed the addSerializer/addDeserializer method in the Call
      object to registerTypeMapping as a convenience.
  
  12) Changed the Stub generation to use the new TypeMapping
      structure to register types.
  
  13) Updated all of AXIS to use URI_CURRENT_SOAP_ENC instead
      of URI_SOAP_ENC.  There was some inconsistencies.
  
  14) Changed the samples/tests as necessary to conform to the new code.
      Only minor/cosmetic changes were necessary.
  
  ----------------------------------------------
  Limitations/Future Work:
  
  A) Glen had some questions about performance.  I don't think that there
  are any major performance problems with the new code, but I agree
  that improvements can be made after this code is committed.
  
  B) I ripped out the code that serialized the TypeMappingRegistry.
  This kind of support will be added later (next week) as serialization of the
  WSDDTypeMapping.
  
  C) The JAX-RPC document is still in flux.  So more changes will be necessary
  as the spec comes into focus.
  
  D) The code still needs to be made more flexible to give the user the
  ability to plug in their own default TypeMapping.  To make this work
  properly, the runtime should always request the factory class names from
  the TypeMapping (i.e. the runtime, wsdd, and stub code should not
  have hard-coded references to BeanSerializerFactory).  There are
  some performance issues involved with this, so might need to add
  Axis only methods to speed up this path.
  
  E) May want to change the default TypeMapping to try and find
  unregistered mappings by automatically converting the namespace
  uri into package names.
  
  F) ???
  
  Revision  Changes    Path
  1.44      +183 -599  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.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- DeserializationContext.java	18 Dec 2001 21:28:21 -0000	1.43
  +++ DeserializationContext.java	26 Jan 2002 02:40:33 -0000	1.44
  @@ -1,10 +1,8 @@
  -package org.apache.axis.encoding;
  -
   /*
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights 
  + * Copyright (c) 2001 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -12,7 +10,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in
  @@ -20,7 +18,7 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:  
  + *    if any, must include the following acknowledgment:
    *       "This product includes software developed by the
    *        Apache Software Foundation (http://www.apache.org/)."
    *    Alternately, this acknowledgment may appear in the software itself,
  @@ -28,7 +26,7 @@
    *
    * 4. The names "Axis" and "Apache Software Foundation" must
    *    not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  + *    software without prior written permission. For written
    *    permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  @@ -55,28 +53,27 @@
    * <http://www.apache.org/>.
    */
   
  -import org.apache.axis.attachments.Attachments; 
  -import org.apache.axis.Constants;
  -import org.apache.axis.MessageContext;
  +
  +package org.apache.axis.encoding;
  +
  +import java.io.IOException;
  +import java.io.Writer;
  +
   import org.apache.axis.Message;
  -import org.apache.axis.message.EnvelopeBuilder;
  -import org.apache.axis.message.EnvelopeHandler;
  -import org.apache.axis.message.HandlerFactory;
  +import org.apache.axis.MessageContext;
  +
  +
   import org.apache.axis.message.IDResolver;
   import org.apache.axis.message.MessageElement;
   import org.apache.axis.message.SAX2EventRecorder;
  -import org.apache.axis.message.SOAPEnvelope;
   import org.apache.axis.message.SOAPHandler;
   import org.apache.axis.utils.NSStack;
  -import org.apache.axis.utils.JavaUtils;
  -import org.apache.axis.utils.XMLUtils;
  -import org.apache.log4j.Category;
  +import org.apache.axis.message.SOAPEnvelope;
  +
  +import org.w3c.dom.Element;
  +
   import org.xml.sax.Attributes;
  -import org.xml.sax.InputSource;
  -import org.xml.sax.Locator;
   import org.xml.sax.SAXException;
  -import org.xml.sax.helpers.DefaultHandler;
  -import org.apache.axis.AxisFault;
   
   import javax.xml.parsers.SAXParser;
   import javax.xml.rpc.namespace.QName;
  @@ -85,605 +82,192 @@
   import java.util.HashMap;
   import java.util.Stack;
   
  -/** 
  - * @author Glen Daniels (gdaniels@macromedia.com)
  +/**
  + * This interface describes the AXIS DeserializationContext, note that
  + * an AXIS compliant DeserializationContext must extend the org.xml.sax.helpers.DefaultHandler.
    */
   
  -public class DeserializationContext extends DefaultHandler
  -{
  -    static Category category =
  -            Category.getInstance(DeserializationContext.class.getName());
  -    
  -    static class LocalIDResolver implements IDResolver
  -    {
  -        HashMap idMap = null;
  -
  -        /**
  -         * Add object associated with id
  -         */
  -        public void addReferencedObject(String id, Object referent)
  -        {
  -            if (idMap == null)
  -                idMap = new HashMap();
  -            
  -            idMap.put(id, referent);
  -        }
  -        
  -        /**
  -         * Get object regferenced by href
  -         */
  -        public Object getReferencedObject(String href)
  -        {
  -            if ((idMap == null) || (href == null))
  -                return null;
  -            return idMap.get(href);
  -        }
  -    }
  -    
  -    private NSStack namespaces = new NSStack();
  -    
  -    private Locator locator;
  -                                             
  -    Stack handlerStack = new Stack();
  -    
  -    SAX2EventRecorder recorder = new SAX2EventRecorder();
  -    public SOAPEnvelope envelope;
  -    
  -    /** A map of IDs -> IDResolvers
  +public interface DeserializationContext extends javax.xml.rpc.encoding.DeserializationContext {
  +
  +    /**
  +     * Create a parser and parse the inputSource
        */
  -    HashMap idMap;
  -    LocalIDResolver localIDs;
  -    
  -    HashMap fixups;
  -    
  -    static final SOAPHandler nullHandler = new SOAPHandler();
  -    
  -    protected MessageContext msgContext;
  -    
  -    protected HandlerFactory initialFactory;
  -    
  -    public boolean doneParsing = false;
  -    protected InputSource inputSource = null;
  -        
  -    public DeserializationContext(MessageContext ctx, EnvelopeBuilder initialHandler)
  -    {
  -        msgContext = ctx;
  -        
  -        envelope = initialHandler.getEnvelope();
  -        envelope.setRecorder(recorder);
  -        
  -        pushElementHandler(new EnvelopeHandler(initialHandler));
  -    }
  -    
  -    MessageElement curElement;
  +    public void parse() throws SAXException;
   
  -    public MessageElement getCurElement() {
  -        return curElement;
  -    }
  -
  -    public void setCurElement(MessageElement el)
  -    {
  -        curElement = el;
  -    }
  -    
  -    public DeserializationContext(InputSource is, MessageContext ctx, 
  -                                  String messageType)
  -    {
  -        EnvelopeBuilder builder = new EnvelopeBuilder(messageType);
  -        
  -        msgContext = ctx;
  -        
  -        envelope = builder.getEnvelope();
  -        envelope.setRecorder(recorder);
  -        
  -        pushElementHandler(new EnvelopeHandler(builder));
  +    /**
  +     * Get current MessageElement
  +     **/
  +    public MessageElement getCurElement();
   
  -        inputSource = is;
  -    }
  -    
  -    public DeserializationContext(InputSource is, MessageContext ctx, 
  -                                  String messageType, SOAPEnvelope env)
  -    {
  -        EnvelopeBuilder builder = new EnvelopeBuilder(env, messageType);
  -        
  -        msgContext = ctx;
  -        
  -        envelope = builder.getEnvelope();
  -        envelope.setRecorder(recorder);
  -        
  -        pushElementHandler(new EnvelopeHandler(builder));
  +    /**
  +     * Set current MessageElement
  +     **/
  +    public void setCurElement(MessageElement el);
   
  -        inputSource = is;
  -    }
  -    
  -    public void parse() throws SAXException
  -    {
  -        if (inputSource != null) {
  -            SAXParser parser = XMLUtils.getSAXParser();
  -            try {
  -                parser.parse(inputSource, this);
  -
  -                // only release the parser for reuse if there wasn't an
  -                // error.  While parsers should be reusable, don't trust
  -                // parsers that died to clean up appropriately.
  -                XMLUtils.releaseSAXParser(parser);
  -            } catch (IOException e) {
  -                throw new SAXException(e);
  -            }
  -            inputSource = null;
  -        }
  -    }
  -    
  -    public MessageContext getMessageContext()
  -    {
  -        return msgContext;
  -    }
  -    
  -    public SOAPEnvelope getEnvelope()
  -    {
  -        return envelope;
  -    }
  -    
  -    public SAX2EventRecorder getRecorder()
  -    {
  -        return recorder;
  -    }
  +    /**
  +     * Get MessageContext         
  +     */
  +    public MessageContext getMessageContext();
       
  -    public ArrayList getCurrentNSMappings()
  -    {
  -        return (ArrayList)namespaces.peek().clone();
  -    }
  +    /**
  +     * Get Envelope               
  +     */
  +    public SOAPEnvelope getEnvelope();
       
  -    /** Grab a namespace prefix
  +    /**
  +     * Get Event Recorder         
        */
  -    public String getNamespaceURI(String prefix)
  -    {
  -        if (curElement != null)
  -            return curElement.getNamespaceURI(prefix);
  +    public SAX2EventRecorder getRecorder();
   
  -        return namespaces.getNamespaceURI(prefix);
  -    }
  -    
  -    public QName getQNameFromString(String qNameStr)
  -    {
  -        if (qNameStr == null)
  -            return null;
  -        
  -        // OK, this is a QName, so look up the prefix in our current mappings.
  -        
  -        int i = qNameStr.indexOf(':');
  -        if (i == -1)
  -            return null;
  -        
  -        String nsURI = getNamespaceURI(qNameStr.substring(0, i));
  -        
  -        //System.out.println("namespace = " + nsURI);
  -        
  -        if (nsURI == null)
  -            return null;
  -        
  -        return new QName(nsURI, qNameStr.substring(i + 1));
  -    }
  +    /**
  +     * Set Event Recorder         
  +     */
  +    public void setRecorder(SAX2EventRecorder recorder);
  +
  +   /**
  +     * Get the Namespace Mappings
  +     **/
  +    public ArrayList getCurrentNSMappings();
       
  +    /** 
  +     * Get the Namespace for a particular prefix
  +     */
  +    public String getNamespaceURI(String prefix);
  +
  +    /**
  +     * Construct a QName from a string of the form <prefix>:<localName>
  +     * @param qNameStr is the prefixed name from the xml text
  +     * @return QName
  +     */
  +    public QName getQNameFromString(String qNameStr);
  +
  +    /** 
  +     * Create a QName for the type of the element defined by localName and
  +     * namespace with the specified attributes.
  +     * @param namespace of the element
  +     * @param localName is the local name of the element
  +     * @param attrs are the attributes on the element
  +     */
       public QName getTypeFromAttributes(String namespace, String localName,
  -                                       Attributes attrs)
  -    {
  -        QName typeQName = null;
  -        
  -        if (typeQName == null) {
  -            QName myQName = new QName(namespace, localName);
  -            if (myQName.equals(SOAPTypeMappingRegistry.SOAP_ARRAY)) {
  -                typeQName = SOAPTypeMappingRegistry.SOAP_ARRAY;
  -            } else if (myQName.equals(SOAPTypeMappingRegistry.SOAP_STRING)) {
  -                typeQName = SOAPTypeMappingRegistry.XSD_STRING;
  -            } else if (myQName.equals(SOAPTypeMappingRegistry.SOAP_BOOLEAN)) {
  -                typeQName = SOAPTypeMappingRegistry.XSD_BOOLEAN;
  -            } else if (myQName.equals(SOAPTypeMappingRegistry.SOAP_DOUBLE)) {
  -                typeQName = SOAPTypeMappingRegistry.XSD_DOUBLE;
  -            } else if (myQName.equals(SOAPTypeMappingRegistry.SOAP_FLOAT)) {
  -                typeQName = SOAPTypeMappingRegistry.XSD_FLOAT;
  -            } else if (myQName.equals(SOAPTypeMappingRegistry.SOAP_INT)) {
  -                typeQName = SOAPTypeMappingRegistry.XSD_INT;
  -            } else if (myQName.equals(SOAPTypeMappingRegistry.SOAP_LONG)) {
  -                typeQName = SOAPTypeMappingRegistry.XSD_LONG;
  -            } else if (myQName.equals(SOAPTypeMappingRegistry.SOAP_SHORT)) {
  -                typeQName = SOAPTypeMappingRegistry.XSD_SHORT;
  -            } else if (myQName.equals(SOAPTypeMappingRegistry.SOAP_BYTE)) {
  -                typeQName = SOAPTypeMappingRegistry.XSD_BYTE;
  -            }
  -        }
  -
  -        if (typeQName != null)
  -            return typeQName;
  -        
  -        if (attrs == null)
  -            return null;
  -        
  -        // Check for type
  -        String type = null;
  -        for (int i=0; i<Constants.URIS_SCHEMA_XSI.length && type==null; i++)
  -            type = attrs.getValue(Constants.URIS_SCHEMA_XSI[i], "type");
  -        
  -        if (type == null)
  -            return null;
  +                                       Attributes attrs);
   
  -        return getQNameFromString(type);
  -    }
  -    
  -    public TypeMappingRegistry getTypeMappingRegistry()
  -    {
  -        return msgContext.getTypeMappingRegistry();
  -    }
  -    
       /**
  -     * Get the MessageElement with a particular ID
  +     * Convenenience method that returns true if the value is nil 
  +     * (due to the xsi:nil) attribute.
  +     * @param attributes are the element attributes.
  +     * @return true if xsi:nil is true
  +     */
  +    public boolean isNil(Attributes attrs);
  +
  +    /**
  +     * Convenience method to get the Deserializer for a specific
  +     * xmlType.
  +     * @param xmlType is QName for a type to deserialize
  +     * @return Deserializer
  +     */
  +    public Deserializer getDeserializerForType(QName xmlType);
  +
  +    /** 
  +     * Get the TypeMapping for this DeserializationContext
  +     */
  +    public TypeMapping getTypeMapping();
  +
  +    /**
  +     * Get the TypeMappingRegistry we're using.
  +     * @return TypeMapping or null
        */ 
  -    public MessageElement getElementByID(String id)
  -    {
  -        if((idMap !=  null)) {
  -            IDResolver resolver = (IDResolver)idMap.get(id);
  -            if(resolver != null) {
  -                Object ret = resolver.getReferencedObject(id);
  -                if (ret instanceof MessageElement)
  -                    return (MessageElement)ret;
  -            }
  -        }
  -        
  -        return null;
  -    }
  -    
  +    public TypeMappingRegistry getTypeMappingRegistry();
  +
       /**
  -     * Get the object referenced by the href.
  -     * The object returned may be a MessageElement requiring deserialization or it 
  -     * may be a deserialized java object.
  -     */
  -    public Object getObjectByRef(String href) {
  -        Object ret= null;
  -        if(href != null){
  -            if((idMap !=  null)){
  -                IDResolver resolver = (IDResolver)idMap.get(href);
  -                if(resolver != null)
  -                   ret = resolver.getReferencedObject(href);
  -            }
  -            if( null == ret && !href.startsWith("#")){
  -                //Could this be an attachment?
  -                Message msg= null;
  -                if(null != (msg=msgContext.getCurrentMessage())){
  -                    Attachments attch= null;
  -                    if( null != (attch= msg.getAttachments())){ 
  -                        try{
  -                        ret= attch.getAttachmentByReference(href);
  -                        }catch(AxisFault e){};
  -                    }
  -                }
  -            }
  -        }
  +     * Get the MessageElement for the indicated id (where id is the #value of an href)
  +     * If the MessageElement has not been processed, the MessageElement will 
  +     * be returned.  If the MessageElement has been processed, the actual object
  +     * value is stored with the id and this routine will return null.
  +     * @param id is the value of an href attribute
  +     * @return MessageElement or null
  +     */ 
  +    public MessageElement getElementByID(String id);
   
  -        return ret; 
  -    }
  -    
       /**
  -     * Add the object associated with this id.
  +     * Gets the MessageElement or actual Object value associated with the href value.  
  +     * The return of a MessageElement indicates that the referenced element has 
  +     * not been processed.  If it is not a MessageElement, the Object is the
  +     * actual deserialized value.  
  +     * In addition, this method is invoked to get Object values via Attachments.
  +     * @param id is the value of an href attribute (or an Attachment id)
  +     * @return MessageElement other Object or null
  +     */ 
  +    public Object getObjectByRef(String href);
  +
  +    /**
  +     * Add the object associated with this id (where id is the value of an id= attribute,
  +     * i.e. it does not start with #).  
        * This routine is called to associate the deserialized object
  -     * with the id specified on the XML element. 
  -    */
  -    public void addObjectById(String _id, Object obj)
  -    {
  -        // The resolver uses the href syntax as the key.
  -        String id = "#" + _id;
  -        if ((idMap == null) || (id == null))
  -            return ;
  -        
  -        IDResolver resolver = (IDResolver)idMap.get(id);
  -        if (resolver == null)
  -            return ;
  -        
  -        resolver.addReferencedObject(id, obj);
  -        return;
  -    }
  -
  -    public void registerFixup(String id, Deserializer dser)
  -    {
  -        if (fixups == null)
  -            fixups = new HashMap();
  -
  -        Deserializer prev = (Deserializer) fixups.put(id, dser);
  -
  -        // If previously registered deserializer, move the targets
  -        if (prev != null && prev != dser)
  -            dser.copyValueTargets(prev);
  -    }
  -    
  -    public void registerElementByID(String id, MessageElement elem)
  -    {
  -        if (localIDs == null)
  -            localIDs = new LocalIDResolver();
  -        
  -        String absID = "#" + id;
  -        
  -        localIDs.addReferencedObject(absID, elem);
  -        
  -        registerResolverForID(absID, localIDs);
  -        
  -        if (fixups != null) {
  -            Deserializer dser = (Deserializer)fixups.get(absID);
  -            if (dser != null) {
  -                elem.setFixupDeserializer(dser);
  -            }
  -        }
  -    }
  -    
  -    public void registerResolverForID(String id, IDResolver resolver)
  -    {
  -        if ((id == null) || (resolver == null)) {
  -            // ??? Throw nullPointerException?
  -            return;
  -        }
  -        
  -        if (idMap == null)
  -            idMap = new HashMap();
  -        
  -        idMap.put(id, resolver);
  -    }
  -    
  -    public int getCurrentRecordPos()
  -    {
  -        if (recorder == null) return -1;
  -        return recorder.getLength() - 1;
  -    }
  -    
  -    protected int startOfMappingsPos = -1;
  -    
  -    public int getStartOfMappingsPos()
  -    {
  -        if (startOfMappingsPos == -1) {
  -            return getCurrentRecordPos() + 1;
  -        }
  -        
  -        return startOfMappingsPos;
  -    }
  -    
  -    public void pushNewElement(MessageElement elem)
  -    {
  -        if (recorder != null) {
  -            recorder.newElement(elem);
  -        }
  -        
  -        elem.setParent(curElement);
  -        curElement = elem;
  -    }
  -    
  -    /****************************************************************
  -     * Management of sub-handlers (deserializers)
  +     * with the id specified on the XML element.
  +     * @param id (id name without the #)
  +     * @param obj is the deserialized object for this id.
        */
  -    
  -    public SOAPHandler getTopHandler()
  -    {
  -        try {
  -            return (SOAPHandler)handlerStack.peek();
  -        } catch (Exception e) {
  -            return null;
  -        }
  -    }
  -    
  -    public void pushElementHandler(SOAPHandler handler)
  -    {
  -        if (category.isDebugEnabled()) {
  -            category.debug(JavaUtils.getMessage("pushHandler00", "" + handler));
  -        }
  -        
  -        handlerStack.push(handler);
  -    }
  -    
  -    /** Replace the handler at the top of the stack.
  -     * 
  -     * This is only used when we have a placeholder Deserializer
  -     * for a referenced object which doesn't know its type until we
  -     * hit the referent.
  -     */
  -    void replaceElementHandler(SOAPHandler handler)
  -    {
  -        handlerStack.pop();
  -        handlerStack.push(handler);
  -    }
  -    
  -    public SOAPHandler popElementHandler()
  -    {
  -        if (!handlerStack.empty()) {
  -            SOAPHandler handler = getTopHandler();
  -            if (category.isDebugEnabled()) {
  -                category.debug(JavaUtils.getMessage("popHandler00", "" + handler));
  -            }
  -            handlerStack.pop();
  -            return handler;
  -        } else {
  -            if (category.isDebugEnabled()) {
  -                category.debug(JavaUtils.getMessage("popHandler00", "(null)"));
  -            }
  -            return null;
  -        }
  -    }
  -    
  -    /****************************************************************
  -     * SAX event handlers
  +    public void addObjectById(String _id, Object obj);
  +
  +   /**
  +     * During deserialization, an element with an href=#id<int>
  +     * may be encountered before the element defining id=id<int> is
  +     * read.  In these cases, the getObjectByRef method above will
  +     * return null.  The deserializer is placed in a table keyed
  +     * by href (a fixup table). After the element id is processed,
  +     * the deserializer is informed of the value so that it can
  +     * update its target(s) with the value.
  +     * @param href (#id syntax)
  +     * @param dser is the deserializer of the element
        */
  -    public void startDocument() throws SAXException {
  -        // Should never receive this in the midst of a parse.
  -        if (recorder != null)
  -            recorder.startDocument();
  -    }
  -    
  -    public void endDocument() throws SAXException {
  -        if (category.isDebugEnabled()) {
  -            category.debug(JavaUtils.getMessage("endDoc00"));
  -        }
  -        if (recorder != null)
  -            recorder.endDocument();
  -        
  -        doneParsing = true;
  -    }
  -    
  -    /** Record the current set of prefix mappings in the nsMappings table.
  -     *
  -     * !!! We probably want to have this mapping be associated with the
  -     *     MessageElements, since they may potentially need access to them
  -     *     long after the end of the prefix mapping here.  (example:
  -     *     when we need to record a long string of events scanning forward
  -     *     in the document to find an element with a particular ID.)
  -     */
  -    public void startPrefixMapping(String prefix, String uri)
  -        throws SAXException
  -    {
  -        if (recorder != null)
  -            recorder.startPrefixMapping(prefix, uri);
  -        
  -        if (startOfMappingsPos == -1)
  -            startOfMappingsPos = getCurrentRecordPos();
  -        
  -        if (prefix != null) {
  -            namespaces.add(uri, prefix);
  -        } else {
  -            namespaces.add(uri, "");
  -        }
  -       
  -        if (category.isDebugEnabled()) {
  -            category.debug(JavaUtils.getMessage("startPrefix00", prefix, uri));
  -        }
  -        
  -        SOAPHandler handler = getTopHandler();
  -        if (handler != null)
  -            handler.startPrefixMapping(prefix, uri);
  -    }
  -    
  -    public void endPrefixMapping(String prefix)
  -        throws SAXException
  -    {
  -        if (category.isDebugEnabled()) {
  -            category.debug(JavaUtils.getMessage("endPrefix00", prefix));
  -        }
  -        
  -        if (recorder != null)
  -            recorder.endPrefixMapping(prefix);
  -        
  -        SOAPHandler handler = getTopHandler();
  -        if (handler != null)
  -            handler.endPrefixMapping(prefix);
  -    }
  -    
  -    public void setDocumentLocator(Locator locator) 
  -    {
  -        if (recorder != null)
  -            recorder.setDocumentLocator(locator);
  -        this.locator = locator;
  -    }
  -
  -    public void characters(char[] p1, int p2, int p3) throws SAXException {
  -        if (recorder != null)
  -            recorder.characters(p1, p2, p3);
  -        if (getTopHandler() != null)
  -            getTopHandler().characters(p1, p2, p3);
  -    }
  -    
  -    public void ignorableWhitespace(char[] p1, int p2, int p3) throws SAXException {
  -        if (recorder != null)
  -            recorder.ignorableWhitespace(p1, p2, p3);
  -        if (getTopHandler() != null)
  -            getTopHandler().ignorableWhitespace(p1, p2, p3);
  -    }
  - 
  -    public void processingInstruction(String p1, String p2) throws SAXException {
  -        // must throw an error since SOAP 1.1 doesn't allow
  -        // processing instructions anywhere in the message
  -        throw new SAXException(JavaUtils.getMessage("noInstructions00"));
  -    }
  -
  -    public void skippedEntity(String p1) throws SAXException {
  -        if (recorder != null)
  -            recorder.skippedEntity(p1);
  -        getTopHandler().skippedEntity(p1);
  -    }
  -
  -    /** This is a big workhorse.  Manage the state of the parser, check for
  -     * basic SOAP compliance (envelope, then optional header, then body, etc).
  -     * 
  -     * This guy also handles monitoring the recording depth if we're recording
  -     * (so we know when to stop), and might eventually do things to help with
  -     * ID/HREF management as well.
  -     * 
  -     */
  -    public void startElement(String namespace, String localName,
  -                             String qName, Attributes attributes)
  -        throws SAXException
  -    {
  -        SOAPHandler nextHandler = null;
  -
  -        if (category.isDebugEnabled()) {
  -            category.debug(JavaUtils.getMessage("startElem00",
  -                    "['" + namespace + "' " + localName + "]"));
  -        }
  -        
  -        String prefix = "";
  -        int idx = qName.indexOf(":");
  -        if (idx > 0)
  -            prefix = qName.substring(0, idx);
  -
  -        if (!handlerStack.isEmpty()) {
  -            nextHandler = getTopHandler().onStartChild(namespace,
  -                                                       localName,
  -                                                       prefix,
  -                                                       attributes,
  -                                                       this);
  -        }
  -        
  -        if (nextHandler == null) {
  -            nextHandler = new SOAPHandler();
  -        }
  -        
  -        pushElementHandler(nextHandler);
  -
  -        nextHandler.startElement(namespace, localName, qName,
  -                                 attributes, this);
  -        
  -        if (recorder != null) {
  -            recorder.startElement(namespace, localName, qName,
  -                                  attributes);
  -            if (!doneParsing)
  -                curElement.setContentsIndex(recorder.getLength());
  -        }
  -        
  -        namespaces.push();
  -        
  -        startOfMappingsPos = -1;
  -    }
  -    
  -    public void endElement(String namespace, String localName, String qName)
  -        throws SAXException
  -    {
  -        if (category.isDebugEnabled()) {
  -            category.debug(JavaUtils.getMessage("endElem00",
  -                    "['" + namespace + "' " + localName + "]"));
  -        }
  -        
  -        if (recorder != null)
  -            recorder.endElement(namespace, localName, qName);
  -        
  -        try {
  -            SOAPHandler handler = popElementHandler();
  -            handler.endElement(namespace, localName, this);
  -            
  -            if (!handlerStack.isEmpty()) {
  -                getTopHandler().onEndChild(namespace, localName, this);
  -            } else {
  -                // We should be done!
  -                if (category.isDebugEnabled()) {
  -                    category.debug(JavaUtils.getMessage("endDoc01"));
  -                }
  -            }
  -            
  -        } finally {
  -            if (curElement != null)
  -                curElement = curElement.getParent();
  -        }
  -    }
  +    public void registerFixup(String href, Deserializer dser);
  +
  +   
  +    /**
  +     * Register the MessageElement with this id (where id is id= form without the #)     
  +     * This routine is called when the MessageElement with an id is read.
  +     * If there is a Deserializer in our fixup list (described above),
  +     * the 'fixup' deserializer is given to the MessageElement.  When the
  +     * MessageElement is completed, the 'fixup' deserializer is informed and
  +     * it can set its targets.
  +     * @param id (id name without the #)
  +     * @param elem is the MessageElement                   
  +     */
  +    public void registerElementByID(String id, MessageElement elem);
  +
  +    /**
  +     * Each id can have its own kind of resolver.  This registers a 
  +     * resolver for the id.
  +     */
  +    public void registerResolverForID(String id, IDResolver resolver);
  +
  +    /**
  +     * Get the current position in the record.
  +     */
  +    public int getCurrentRecordPos();
  +
  +    /**
  +     * Get the start of the mapping position  
  +     */
  +    public int getStartOfMappingsPos();
  +
  +    /**
  +     * Push the MessageElement into the recorder
  +     */
  +    public void pushNewElement(MessageElement elem);
  +
  +    /**
  +     * Handler management methods
  +     */
  +    public SOAPHandler getTopHandler();
  +    public void pushElementHandler(SOAPHandler handler);
  +    public void replaceElementHandler(SOAPHandler handler);
  +    public SOAPHandler popElementHandler();
  +
  +    /**
  +     * Return if done parsing document.
  +     */
  +    public boolean isDoneParsing();
   }
  +
   
  
  
  
  1.28      +220 -359  xml-axis/java/src/org/apache/axis/encoding/Deserializer.java
  
  Index: Deserializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/Deserializer.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- Deserializer.java	31 Dec 2001 20:35:07 -0000	1.27
  +++ Deserializer.java	26 Jan 2002 02:40:33 -0000	1.28
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights 
  + * Copyright (c) 2001 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -10,7 +10,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in
  @@ -18,7 +18,7 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:  
  + *    if any, must include the following acknowledgment:
    *       "This product includes software developed by the
    *        Apache Software Foundation (http://www.apache.org/)."
    *    Alternately, this acknowledgment may appear in the software itself,
  @@ -26,7 +26,7 @@
    *
    * 4. The names "Axis" and "Apache Software Foundation" must
    *    not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  + *    software without prior written permission. For written
    *    permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  @@ -53,391 +53,252 @@
    * <http://www.apache.org/>.
    */
   
  +
   package org.apache.axis.encoding;
   
  -import org.apache.axis.Constants;
  +import java.io.IOException;
  +import java.io.Writer;
  +
  +import org.apache.axis.Message;
  +import org.apache.axis.MessageContext;
  +
  +import org.apache.axis.encoding.Target;
   
  -import org.apache.axis.message.EnvelopeHandler;
  +import org.apache.axis.message.IDResolver;
   import org.apache.axis.message.MessageElement;
   import org.apache.axis.message.SAX2EventRecorder;
  -import org.apache.axis.message.SAXOutputter;
   import org.apache.axis.message.SOAPHandler;
  -import org.apache.axis.utils.JavaUtils;
  -import org.apache.log4j.Category;
  +import org.apache.axis.utils.NSStack;
  +import org.apache.axis.message.SOAPEnvelope;
  +
  +import org.w3c.dom.Element;
  +
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
   
  +import javax.xml.parsers.SAXParser;
   import javax.xml.rpc.namespace.QName;
  -import java.io.StringWriter;
  -import java.lang.reflect.Field;
  -import java.lang.reflect.InvocationTargetException;
  -import java.lang.reflect.Method;
  -import java.util.Enumeration;
  +import java.io.IOException;
  +import java.util.ArrayList;
  +import java.util.HashMap;
  +import java.util.Stack;
   import java.util.Vector;
   
  -/** The Deserializer base class.
  +/**
  + * This interface describes the AXIS Deserializer. 
  + * A compliant implementiation must extend either
  + * the AXIS SoapHandler (org.apache.axis.message.SOAPHandler)
  + * or the AXIS DeserializerImpl (org.apache.axis.encoding.DeserializerImpl)
    * 
  - * Still needs some work.
  - * 
  - * @author Glen Daniels (gdaniels@allaire.com)
  - */
  + * The DeserializerImpl provides a lot of the default behavior including the
  + * support for id/href.  So you may want to try extending it as opposed to
  + * extending SoapHandler.
  + *
  + * An Axis compliant Deserializer must provide one or more 
  + * of the following methods:
  + *
  + * public <constructor>(Class javaType, QName xmlType)
  + * public <constructor>()
  + *
  + * This will allow for construction of generic factories that introspect the class 
  + * to determine how to construct a deserializer.
  + * The xmlType, javaType arguments are filled in with the values known by the factory. 
  +g */
  +public interface Deserializer extends javax.xml.rpc.encoding.Deserializer, Callback {
  +    
  +    /** 
  +     * Get the deserialized value.
  +     * @return Object representing deserialized value or null
  +     */
  +    public Object getValue();
  +
  +    /** 
  +     * Set the deserialized value.
  +     * @param Object representing deserialized value
  +     */
  +    public void setValue(Object value);
  +
  +    /** 
  +     * If the deserializer has component values (like ArrayDeserializer)
  +     * this method gets the specific component via the hint.
  +     * The default implementation returns null.
  +     * @return Object representing deserialized value or null
  +     */
  +    public Object getValue(Object hint);
   
  -public class Deserializer extends SOAPHandler
  -{
  -    static Category category =
  -            Category.getInstance(Deserializer.class.getName());
  +    /** 
  +     * If the deserializer has component values (like ArrayDeserializer)
  +     * this method sets the specific component via the hint.
  +     * The default implementation does nothing.
  +     * @param Object representing deserialized value or null
  +     */
  +    public void setValue(Object value, Object hint) throws SAXException;
   
  -    protected Object value = null;
  +    /**
  +     * For deserializers of non-primitives, the value may not be
  +     * known until later (due to multi-referencing).  In such
  +     * cases the deserializer registers Target object(s).  When
  +     * the value is known, the set(value) will be invoked for
  +     * each Target registered with the Deserializer.  The Target
  +     * object abstracts the function of setting a target with a
  +     * value.  See the Target interface for more info.
  +     * @param Target
  +     */
  +    public void registerValueTarget(Target target);
   
  -    // isEnded is set when the endElement is called
  -    protected boolean isEnded = false;
  +    /**
  +     * Get the Value Targets of the Deserializer.
  +     * @return Vector of Target objects or null
  +     */
  +    public Vector getValueTargets();
   
  -    protected Vector targets = null;
  -    
  -    public Object getValue()
  -    {
  -        return value;
  -    }
  -    public void setValue(Object value)
  -    {
  -        this.value = value;
  -    }
  -
  -    /////////////////////////////////////////////////////////////
  -    //  Reflection-based insertion of values into target objects
  -    //  once deserialization is complete.
  -    //
  -    public interface Target {
  -        public void set(Object value) throws SAXException;
  -
  -    }
  -
  -    public static class FieldTarget implements Target {
  -        private Object targetObject;
  -        private Field targetField;
  -
  -        public FieldTarget(Object targetObject, Field targetField)
  -        {
  -            this.targetObject = targetObject;
  -            this.targetField = targetField;
  -        }
  -        
  -        public FieldTarget(Object targetObject, String fieldName)
  -            throws NoSuchFieldException
  -        {
  -            Class cls = targetObject.getClass();
  -            targetField = cls.getField(fieldName);
  -            this.targetObject = targetObject;
  -        }
  -
  -        public void set(Object value) throws SAXException {
  -            try {
  -                targetField.set(targetObject, value);
  -            } catch (IllegalAccessException accEx) {
  -                accEx.printStackTrace();
  -                throw new SAXException(accEx);
  -            } catch (IllegalArgumentException argEx) {
  -                argEx.printStackTrace();
  -                throw new SAXException(argEx);
  -            }
  -        }
  -    }
  -    
  -    public static class MethodTarget implements Target {
  -        private Object targetObject;
  -        private Method targetMethod;
  -        private static final Class [] objArg = new Class [] { Object.class };
  -
  -        public MethodTarget(Object targetObject, String methodName)
  -            throws NoSuchMethodException
  -        {
  -            this.targetObject = targetObject;
  -            Class cls = targetObject.getClass();
  -            targetMethod = cls.getMethod(methodName, objArg);
  -        }
  -        
  -        public void set(Object value) throws SAXException {
  -            try {
  -                targetMethod.invoke(targetObject, new Object [] { value });
  -            } catch (IllegalAccessException accEx) {
  -                accEx.printStackTrace();
  -                throw new SAXException(accEx);
  -            } catch (IllegalArgumentException argEx) {
  -                argEx.printStackTrace();
  -                throw new SAXException(argEx);
  -            } catch (InvocationTargetException targetEx) {
  -                targetEx.printStackTrace();
  -                throw new SAXException(targetEx);
  -            }
  -        }
  -    }
  -
  -    class CallbackTarget implements Target {
  -        public ValueReceiver target;
  -        public Object hint;
  -        CallbackTarget(ValueReceiver target, Object hint)
  -        {
  -            this.target = target;
  -            this.hint = hint;
  -        }
  -        
  -        public void set(Object value) throws SAXException {
  -            target.valueReady(value, hint);
  -        }
  -    }
  -
  -    public void registerCallback(ValueReceiver target, Object hint)
  -    {
  -        if (target == null)
  -            return;
  -        
  -        registerValueTarget(new CallbackTarget(target, hint));
  -    }
  -    
  +   /**
  +     * Add someone else's targets to our own (see DeserializationContext)
  +     *
  +     * The DeserializationContext only allows one Deserializer to  
  +     * wait for a unknown multi-ref'ed value.  So to ensure
  +     * that all of the targets are updated, this method is invoked
  +     * to copy the Target objects to the waiting Deserializer.
  +     * @param other is the Deserializer to copy targets from.
  +     */
  +    public void copyValueTargets(Deserializer other);
   
  -    public void registerValueTarget(Target target)
  -    {
  -        if (targets == null)
  -            targets = new Vector();
  -        
  -        targets.addElement(target);
  -    }
  -    
  -    public void registerValueTarget(Object target, String fieldName)
  -        throws NoSuchFieldException
  -    {
  -        registerValueTarget(new FieldTarget(target, fieldName));
  -    }
  -    
  -    /** Add someone else's targets to our own (see DeserializationContext)
  -     * 
  +    /**
  +     * Some deserializers (ArrayDeserializer) require
  +     * all of the component values to be known before the
  +     * value is complete.
  +     * (For the ArrayDeserializer this is important because
  +     * the elements are stored in an ArrayList, and all values
  +     * must be known before the ArrayList is converted into the
  +     * expected array.
  +     *
  +     * This routine is used to indicate when the components are ready.
  +     * The default (true) is useful for most Deserializers.
        */
  -    public void copyValueTargets(Deserializer other)
  -    {
  -        if ((other == null) || (other.targets == null))
  -            return;
  -        
  -        if (targets == null)
  -            targets = new Vector();
  -        
  -        Enumeration e = other.targets.elements();
  -        while (e.hasMoreElements()) {
  -            targets.addElement(e.nextElement());
  -        }
  -    }
  -    
  +    public boolean componentsReady();
  +
       /** 
  -     * Store the value into the target
  +     * The valueComplete() method is invoked when the
  +     * end tag of the element is read.  This results
  +     * in the setting of all registered Targets (see
  +     * registerValueTarget).
  +     * Note that the valueComplete() only processes
  +     * the Targets if componentReady() returns true.
  +     * So if you override componentReady(), then your
  +     * specific Deserializer will need to call valueComplete()
  +     * when your components are ready (See ArrayDeserializer)
        */
  -    public void valueComplete() throws SAXException
  -    {
  -        if (componentsReady()) {            
  -            if (targets != null) {
  -                Enumeration e = targets.elements();
  -                while (e.hasMoreElements()) {
  -                    Target target = (Target)e.nextElement();
  -                    target.set(value);
  -                    if (category.isDebugEnabled()) {
  -                        category.debug(JavaUtils.getMessage("setValueInTarget00",
  -                                                            "" + value, "" + target));
  -                    }
  -                }
  -            }
  -        }
  -    }
  -    
  -    private int startIdx = 0;
  -    private int endIdx = -1;
  -    protected boolean isHref = false;
  -    protected boolean isNil  = false;  // xsd:nil attribute is set to true
  -    protected String id = null;  // Set to the id of the element
  -    
  -    /** Subclasses override this
  +    public void valueComplete() throws SAXException;
  +
  +
  +    /**
  +     * The following are the SAX specific methods.
  +     * DeserializationImpl provides default behaviour, which
  +     * in most cases is appropriate.
  +     */
  +
  +    /**
  +     * This method is invoked when an element start tag is encountered.
  +     * DeserializerImpl provides default behavior, which involves the following:
  +     *   - directly handling the deserialization of a nill value
  +     *   - handling the registration of the id value.
  +     *   - handling the registration of a fixup if this element is an href.
  +     *   - calling onStartElement to do the actual deserialization if not nill or href cases.
  +     * @param namespace is the namespace of the element
  +     * @param localName is the name of the element
  +     * @param qName is the prefixed qName of the element
  +     * @param attributes are the attributes on the element...used to get the type
  +     * @param context is the DeserializationContext
  +     *
  +     * Normally a specific Deserializer (FooDeserializer) should extend DeserializerImpl.
  +     * Here is the flow that will occur in such cases:
  +     *   1) DeserializerImpl.startElement(...) will be called and do the id/href/nill stuff.
  +     *   2) If real deserialization needs to take place DeserializerImpl.onStartElement will be
  +     *      invoked, which will attempt to install the specific Deserializer (FooDeserializer)
  +     *   3) The FooDeserializer.startElement(...) will be called to do the Foo specific stuff.
  +     *      This results in a call to FooDeserializer.onStartElement(...) if startElement was
  +     *      not overridden.
  +     *   4) The onChildElement(...) method is called for each child element.  Nothing occurs
  +     *      if not overridden.  The FooDeserializer.onStartChild(...) method should return 
  +     *      the deserializer for the child element.
  +     *   5) When the end tag is reached, the endElement(..) method is invoked.  The default 
  +     *      behavior is to handle hrefs/ids, call onEndElement and then call the Deserializer
  +     *      valueComplete method.
  +     * 
  +     * So the methods that you potentially want to override are:
  +     *   onStartElement, onStartChild, componentsReady, set(object, hint)
  +     *
  +     * You probably should not override startElement or endElement.
  +     * If you need specific behaviour at the end of the element consider overriding
  +     * onEndElement.
  +     *
  +     * See the pre-existing Deserializers for more information.
  +     */
  +    public void startElement(String namespace, String localName,
  +                             String qName, Attributes attributes,
  +                             DeserializationContext context)
  +        throws SAXException;
  +       
  +    /**
  +     * This method is invoked after startElement when the element requires
  +     * deserialization (i.e. the element is not an href and the value is not nil.)
  +     * DeserializerImpl provides default behavior, which simply
  +     * involves obtaining a correct Deserializer and plugging its handler.
  +     * @param namespace is the namespace of the element
  +     * @param localName is the name of the element
  +     * @param qName is the prefixed qname of the element
  +     * @param attributes are the attributes on the element...used to get the type
  +     * @param context is the DeserializationContext
        */
       public void onStartElement(String namespace, String localName,
                                String qName, Attributes attributes,
                                DeserializationContext context)
  -        throws SAXException
  -    {
  -        // If I'm the base class, try replacing myself with an
  -        // appropriate deserializer gleaned from type info.
  -        if (this.getClass().equals(Deserializer.class)) {
  -            QName type = context.getTypeFromAttributes(namespace,
  -                                                       localName,
  -                                                       attributes);
  -            
  -            if (category.isDebugEnabled()) {
  -                category.debug(JavaUtils.getMessage("gotType00", "Deser", "" + type));
  -            }
  -            
  -            // We know we're deserializing, and we can't seem to figure
  -            // out a type... so let's give them a string.
  -            // ??? Is this the right thing to do?
  -            if (type != null) {
  -                Deserializer dser = 
  -                                   context.getTypeMappingRegistry().getDeserializer(type);
  -                if (dser != null) {
  -                    dser.copyValueTargets(this);
  -                    context.replaceElementHandler(dser);
  -                    // And don't forget to give it the start event...
  -                    dser.startElement(namespace, localName, qName,
  -                                      attributes, context);
  -                }
  -            } else {
  -                startIdx = context.getCurrentRecordPos();
  -            }
  -        }
  -    }
  -    
  +        throws SAXException;
  +
  +    /**
  +     * onStartChild is called on each child element.
  +     * The default behavior supplied by DeserializationImpl is to do nothing.
  +     * A specific deserializer may perform other tasks.  For example a 
  +     * BeanDeserializer will construct a deserializer for the indicated 
  +     * property and return it.
  +     * @param namespace is the namespace of the child element
  +     * @param localName is the local name of the child element
  +     * @param prefix is the prefix used on the name of the child element
  +     * @param attributes are the attributes of the child element
  +     * @param context is the deserialization context.
  +     * @return is a Deserializer to use to deserialize a child (must be
  +     * a derived class of SOAPHandler) or null if no deserialization should
  +     * be performed.
  +     */
       public SOAPHandler onStartChild(String namespace, String localName,
                                String prefix, Attributes attributes,
                                DeserializationContext context)
  -        throws SAXException
  -    {
  -        return null;
  -    }
  -    
  -    public void startElement(String namespace, String localName,
  -                             String qName, Attributes attributes,
  -                             DeserializationContext context)
  -        throws SAXException
  -    {
  -        // If the xsi:nil attribute, set the value to null and return since
  -        // there is nothing to deserialize.
  -        String nil = null;
  -        for (int i = 0; i < Constants.URIS_SCHEMA_XSI.length && nil == null; i++)
  -            nil = attributes.getValue(Constants.URIS_SCHEMA_XSI[i], "nil");
  -        if (nil != null && nil.equals("true")) {
  -          value = null;
  -          isNil = true;
  -          return;
  -        }
  -
  -        // If this element has an id, then associate the value with the id.
  -        // (Prior to this association, the MessageElement of the element is
  -        // associated with the id. Failure to replace the MessageElement at this
  -        // point will cause an infinite loop during deserialization if the 
  -        // current element contains child elements that cause an href back to this id.)
  -        // Also note that that endElement() method is responsible for the final
  -        // assoication of this id with the completed value.
  -        id = attributes.getValue("id");
  -        if (id != null) {
  -            context.addObjectById(id, value);
  -            if (category.isDebugEnabled()) {
  -                category.debug(JavaUtils.getMessage("deserInitPutValueDebug00", "" + value, id));
  -            }     
  -        }
  -
  -        String href = attributes.getValue("href");
  -        if (href != null) {
  -            isHref = true;
  -
  -            Object ref = context.getObjectByRef(href);            
  -            if (category.isDebugEnabled()) {
  -                category.debug(JavaUtils.getMessage(
  -                        "gotForID00",
  -                        new String[] {"" + ref, href, "" + ref.getClass()}));
  -            }
  -            
  -            if (ref == null) {
  -                // Nothing yet... register for later interest.
  -                context.registerFixup(href, this);
  -            }
  -            
  -            if (ref instanceof MessageElement) {
  -                context.replaceElementHandler(new EnvelopeHandler(this));
  -
  -                SAX2EventRecorder r = context.recorder;
  -                context.recorder = null;
  -                ((MessageElement)ref).publishToHandler(context);
  -                context.recorder = r;
  -            } else {
  -                // If the ref is not a MessageElement, then it must be an
  -                // element that has already been deserialized.  Use it directly.
  -                value = ref;
  -                valueComplete();
  -            }
  -            
  -            // !!! INSERT DEALING WITH ATTACHMENTS STUFF HERE?
  -        } else {
  -            isHref = false;
  -            onStartElement(namespace, localName, qName, attributes,
  -                           context);
  -        }
  -    }
  -    
  -    /**
  -     * Subclasses override this to do custom functionality at the
  -     * end of their enclosing element.  This will NOT be called
  -     * for HREFs...
  -     * 
  +        throws SAXException;
  +
  +    /** 
  +     * endElement is called when the end element tag is reached.
  +     * It handles href/id information for multi-ref processing
  +     * and invokes the valueComplete() method of the deserializer
  +     * which sets the targets with the deserialized value.
  +     * @param namespace is the namespace of the child element
  +     * @param localName is the local name of the child element
  +     * @param context is the deserialization context
        */
  -    public void onEndElement(String namespace, String localName,
  +    public void endElement(String namespace, String localName,
                              DeserializationContext context)
  -        throws SAXException
  -    {
  -        // If we only have SAX events, but someone really wanted a
  -        // value, try sending them the contents of this element
  -        // as a String...
  -        // ??? Is this the right thing to do here?
  -        
  -        if (this.getClass().equals(Deserializer.class) &&
  -            targets != null &&
  -            !targets.isEmpty()) {
  -            endIdx = context.getCurrentRecordPos();
  -            
  -            StringWriter writer = new StringWriter();
  -            SerializationContext serContext = 
  -                        new SerializationContext(writer,
  -                                                 context.getMessageContext());
  -            serContext.setSendDecl(false);
  -            SAXOutputter so = new SAXOutputter(serContext);
  -            context.curElement.publishContents(so);
  -            
  -            value = writer.getBuffer().toString();
  -        }
  -    }
  -    
  -    public final void endElement(String namespace, String localName,
  -                           DeserializationContext context)
  -        throws SAXException
  -    {
  +        throws SAXException;
   
  -        isEnded = true;
  -        if (!isHref) {
  -            onEndElement(namespace, localName, context);
  -        }
  -        
  -        // Time to call valueComplete to copy the value to 
  -        // the targets.  First a call is made to componentsReady
  -        // to ensure that all components are ready.
  -
  -        if (componentsReady())
  -            valueComplete();
  -
  -        // If this element has an id, then associate the value with the id.
  -        // Subsequent hrefs to the id will obtain the value directly.
  -        // This is necessary for proper multi-reference deserialization.
  -        if (id != null) {
  -            context.addObjectById(id, value);
  -            if (category.isDebugEnabled()) {
  -                category.debug(JavaUtils.getMessage("deserPutValueDebug00", "" + value, id));
  -            }     
  -        }
  -    }
  +   /**
  +     * onEndElement is called by endElement.  It is not called
  +     * if the element has an href.
  +     * @param namespace is the namespace of the child element
  +     * @param localName is the local name of the child element
  +     * @param context is the deserialization context
  +     */
  +    public void onEndElement(String namespace, String localName,
  +                           DeserializationContext context)
  +        throws SAXException;
   
  -    /**
  -     * Return whether components are ready. 
  -     * Use the default componentsReady if the  
  -     * Deserializer value is used directly.  For arrays,
  -     * componentsReady is overridden (since the
  -     * ArraySerializer value is an ArrayList which will
  -     * be converted into an actual array).  
  -     * If componentsReady is overridden, the
  -     * actual Deserializer is responsible for calling valueComplete
  -     * when the value is ready.
  -     */
  -    protected boolean componentsReady() {
  -        return true; 
  -    }
   }
  +
  +
  
  
  
  1.7       +19 -22    xml-axis/java/src/org/apache/axis/encoding/DeserializerFactory.java
  
  Index: DeserializerFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/DeserializerFactory.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DeserializerFactory.java	23 Dec 2001 12:33:32 -0000	1.6
  +++ DeserializerFactory.java	26 Jan 2002 02:40:33 -0000	1.7
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights 
  + * Copyright (c) 2001 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -10,7 +10,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in
  @@ -18,7 +18,7 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:  
  + *    if any, must include the following acknowledgment:
    *       "This product includes software developed by the
    *        Apache Software Foundation (http://www.apache.org/)."
    *    Alternately, this acknowledgment may appear in the software itself,
  @@ -26,7 +26,7 @@
    *
    * 4. The names "Axis" and "Apache Software Foundation" must
    *    not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  + *    software without prior written permission. For written
    *    permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  @@ -53,27 +53,24 @@
    * <http://www.apache.org/>.
    */
   
  -package org.apache.axis.encoding;
   
  -import java.beans.IntrospectionException;
  +package org.apache.axis.encoding;
   
   /**
  - * DeserializerFactories produce preconfigured deserializers designed
  - * to convert an XML Element into the desired Java Class.
  + * This interface describes the AXIS DeserializerFactory.
  + *
  + * An Axis compliant Serializer Factory must provide one or more 
  + * of the following methods:
  + *
  + * public static create(Class javaType, QName xmlType)
  + * public <constructor>(Class javaType, QName xmlType)
  + * public <constructor>()
  + *
  + * The deployment code will attempt to invoke these methods in the above order.
  + * The xmlType, javaType arguments are filled in with the values supplied during the
  + * deployment registration of the factory.
    */
  -public interface DeserializerFactory extends java.io.Serializable {
  +public interface DeserializerFactory extends javax.xml.rpc.encoding.DeserializerFactory { 
  +}
   
  -    /**
  -     * Specifify the class to be returned by the deserializer produced
  -     * by this factory.
  -     * @param cls the desired class
  -     * @exception IntrospectionException unable to introspect the desired
  -     * class or the class has the wrong type signature for its intended use.
  -     */
  -    public void setJavaClass(Class cls) throws IntrospectionException;
   
  -    /**
  -     * Obtain the desired deserializer. 
  -     */
  -    public Deserializer getDeserializer();
  -}
  
  
  
  1.72      +177 -593  xml-axis/java/src/org/apache/axis/encoding/SerializationContext.java
  
  Index: SerializationContext.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/SerializationContext.java,v
  retrieving revision 1.71
  retrieving revision 1.72
  diff -u -r1.71 -r1.72
  --- SerializationContext.java	11 Jan 2002 18:15:19 -0000	1.71
  +++ SerializationContext.java	26 Jan 2002 02:40:33 -0000	1.72
  @@ -53,193 +53,112 @@
    * <http://www.apache.org/>.
    */
   
  +
   package org.apache.axis.encoding;
   
  -import org.apache.axis.AxisEngine;
  -import org.apache.axis.Constants;
  +import java.io.IOException;
  +import java.io.Writer;
  +
  +import javax.xml.rpc.namespace.QName;
  +
   import org.apache.axis.Message;
   import org.apache.axis.MessageContext;
  -import org.apache.axis.attachments.Attachments;
  -import org.apache.axis.client.Call;
  -import org.apache.axis.utils.JavaUtils;
  -import org.apache.axis.utils.Mapping;
  -import org.apache.axis.utils.NSStack;
  -import org.apache.axis.utils.XMLUtils;
  -import org.apache.log4j.Category;
  -import org.w3c.dom.Attr;
  +
   import org.w3c.dom.Element;
  -import org.w3c.dom.NamedNodeMap;
  -import org.w3c.dom.Node;
  -import org.w3c.dom.NodeList;
  -import org.w3c.dom.Text;
  +
   import org.xml.sax.Attributes;
  -import org.xml.sax.helpers.AttributesImpl;
   
  -import javax.xml.rpc.namespace.QName;
  -import java.io.IOException;
  -import java.io.Writer;
  -import java.util.ArrayList;
  -import java.util.Date;
  -import java.util.HashMap;
  -import java.util.HashSet;
  -import java.util.Iterator;
  -import java.util.Stack;
  -
  -/** Manage a serialization, including keeping track of namespace mappings
  - * and element stacks.
  - *
  - * @author Glen Daniels (gdaniels@macromedia.com)
  - * @author Rich Scheuerle <sc...@us.ibm.com>
  +/**
  + * This interface describes the AXIS SerializationContext.
    */
  -public class SerializationContext
  -{
  -    static Category category =
  -            Category.getInstance(SerializationContext.class.getName());
  -
  -    public NSStack nsStack = new NSStack();
  -
  -    boolean writingStartTag = false;
  -    boolean onlyXML = true;
  -    int indent=0;
  -    boolean startOfDocument = true;
  -
  -    Stack elementStack = new Stack();
  -    Writer writer;
  -
  -    int lastPrefixIndex = 1;
  -
  -    private MessageContext msgContext;
  -
  -    /**
  -     * Should the XML be "pretty" printed on serialization?  If false, the
  -     * XML will be sent out verbatim.  If true, ignorable white space may be
  -     * inserted or removed.
  -     */
  -    private boolean pretty = false;
  -
  -    public boolean getPretty() {
  -        return pretty;
  -    }
  -
  -    public void setPretty(boolean pretty) {
  -        this.pretty = pretty;
  -    }
  -
  -    /**
  -     * Should I write out objects as multi-refs?
  -     *
  -     * !!! For now, this is an all-or-nothing flag.  Either ALL objects will
  -     * be written in-place as hrefs with the full serialization at the end
  -     * of the body, or we'll write everything inline (potentially repeating
  -     * serializations of identical objects).
  -     */
  -    private boolean doMultiRefs = false;
  -
  -    /**
  -     * Should I send an XML declaration?
  -     */
  -    private boolean sendXMLDecl = true;
  -
  -    /**
  -     * Should I send xsi:type attributes?
  -     */
  -    private boolean sendXSIType = true;
  -
  -    /**
  -     * A place to hold objects we cache for multi-ref serialization, and
  -     * remember the IDs we assigned them.
  -     */
  -    private HashMap multiRefValues = null;
  -    private int multiRefIndex = -1;
  -
  -    /**
  -     * These three variables are necessary to process multi-level object graphs for multi-ref
  -     * serialization. 
  -     * While writing out nested multi-ref objects (via outputMultiRef), we 
  -     * will fill the secondLevelObjects vector with any new objects encountered.
  -     * The outputMultiRefsFlag indicates whether we are currently within the
  -     * outputMultiRef() method (so that serialization() knows to update the 
  -     * secondLevelObjects vector).
  -     * The forceSer variable is the trigger to force actual serialization of the indicated object.
  -     */
  -    private HashSet secondLevelObjects = null;
  -    private Object forceSer = null;
  -    private boolean outputMultiRefsFlag = false;
  -    
  -    public SerializationContext(Writer writer)
  -    {
  -        this.writer = writer;
  -    }
  -    
  -    public SerializationContext(Writer writer, MessageContext msgContext)
  -    {
  -        this.writer = writer;
  -        this.msgContext = msgContext;
  -
  -        AxisEngine engine = null ;
  -        if ( msgContext != null ) {
  -            engine = msgContext.getAxisEngine();
  -            Boolean shouldSendDecl = (Boolean)engine.getOption(
  -                                                  AxisEngine.PROP_XML_DECL);
  -            if (shouldSendDecl != null)
  -                sendXMLDecl = shouldSendDecl.booleanValue();
  -            
  -            Boolean shouldSendMultiRefs = 
  -                  (Boolean)msgContext.getProperty(AxisEngine.PROP_DOMULTIREFS);
  -            
  -            if (shouldSendMultiRefs == null)
  -                shouldSendMultiRefs =
  -                        (Boolean)engine.getOption(AxisEngine.PROP_DOMULTIREFS);
  -            
  -            if (shouldSendMultiRefs != null)
  -                doMultiRefs = shouldSendMultiRefs.booleanValue();
  -
  -            // The SEND_TYPE_ATTR and PROP_SEND_XSI options indicate
  -            // whether the elements should have xsi:type attributes.
  -            // Only turn this off is the user tells us to
  -            if ( !msgContext.isPropertyTrue(Call.SEND_TYPE_ATTR, true ))
  -                sendXSIType = false ;
  -            
  -            Boolean opt = (Boolean)engine.getOption(AxisEngine.PROP_SEND_XSI);
  -            if ((opt != null) && (opt.equals(Boolean.FALSE))) {
  -                sendXSIType = false;
  -            }
  -        }
  -    }
  -    
  +public interface SerializationContext extends javax.xml.rpc.encoding.SerializationContext {
  +
  +
  +    /**
  +     * Serialize the indicated value as an element named qName.  The attributes object are 
  +     * additional attributes that will be serialized with the qName.  The value
  +     * could be serialized directly or could be serialized as an href (with the
  +     * actual serialize taking place later)
  +     * @param qName is the QName of the element
  +     * @param attributes are additional attributes
  +     * @param value is the object to serialize
  +     * @param javaType is the "real" type of the value.  For primitives, the value is the
  +     * associated java.lang class.  So the javaType is needed to know that the value 
  +     * is really a wrapped primitive.
  +     */
  +    public void serialize(QName qName, Attributes attributes, Object value, Class javaType) 
  +        throws IOException;
  +
  +    /**
  +     * Invoked to do the actual serialization of the qName (called by serialize above).
  +     * additional attributes that will be serialized with the qName. 
  +     * @param qName is the QName of the element
  +     * @param attributes are additional attributes
  +     * @param value is the object to serialize
  +     * @param javaType is the "real" type of the value.  For primitives, the value is the
  +     * associated java.lang class.  So the javaType is needed to know that the value 
  +     * is really a wrapped primitive.
  +     */
  +    public void serializeActual(QName qName, Attributes attributes, Object value, Class javaType)
  +        throws IOException;
  +
  +    /**
  +     * Obtains the type attribute that should be serialized and returns the new list of Attributes
  +     * @param attributes of the qname
  +     * @param type is the qname of the type
  +     * @return new list of Attributes
  +     */
  +    public Attributes setTypeAttribute(Attributes attributes, QName type);
  +
  +    /**
  +     * Convenience method to get the Serializer for a specific
  +     * java type
  +     * @param javaType is Class for a type to serialize
  +     * @return Serializer
  +     */ 
  +    public Serializer getSerializerForJavaType(Class javaType) ; 
  +
  +    /**
  +     * Get whether the serialization should be pretty printed.
  +     * @return true/false
  +     */
  +    public boolean getPretty();
  +
  +    /**
  +     * Indicate whether the serialization should be pretty printed.
  +     * @param pretty true/false
  +     */
  +    public void setPretty(boolean pretty);
  +
  +    /**
  +     * Set whether we are doing multirefs.
  +     * @param shouldDo true/false
  +     */ 
  +    public void setDoMultiRefs (boolean shouldDo);
  +
       /**
  -     * Set whether we are doing multirefs
  +     * Set whether or not we should write XML declarations.
  +     * @param sendDecl true/false
        */ 
  -    public void setDoMultiRefs (boolean shouldDo)
  -    {
  -        doMultiRefs = shouldDo;
  -    }
  +    public void setSendDecl(boolean sendDecl);
   
       /**
  -     * Set whether or not we should write XML declarations
  +     * Get whether or not to write xsi:type attributes.
  +     * @return true/false
        */ 
  -    public void setSendDecl(boolean sendDecl)
  -    {
  -        sendXMLDecl = sendDecl;
  -    }
  +    public boolean shouldSendXSIType();
   
       /**
  -     * Set whether or not to write xsi:type attributes
  +     * Get the TypeMapping we're using.
  +     * @return TypeMapping or null
        */ 
  -    public boolean shouldSendXSIType() {
  -        return sendXSIType;
  -    }
  +    public TypeMapping getTypeMapping();
   
       /**
  -     * Obtain a copy of the TypeMappingRegistry we're using
  +     * Get the TypeMappingRegistry we're using.
  +     * @return TypeMapping or null
        */ 
  -    public TypeMappingRegistry getTypeMappingRegistry()
  -    {
  -        if (msgContext == null)
  -            return null;
  -        
  -        return msgContext.getTypeMappingRegistry();
  -    }
  +    public TypeMappingRegistry getTypeMappingRegistry();
   
       /**
        * Get a prefix for a namespace URI.  This method will ALWAYS
  @@ -247,435 +166,100 @@
        * serialization, we return the previous prefix.  If it is not mapped,
        * we will add a new mapping and return a generated prefix of the form
        * "ns<num>".
  +     * @param uri is the namespace uri
  +     * @param defaultPrefix optional parameter which is the default prefix
  +     * @return prefix
        */ 
  -    public String getPrefixForURI(String uri)
  -    {
  -        return getPrefixForURI(uri, null);
  -    }
  -    
  +    public String getPrefixForURI(String uri);
  +    public String getPrefixForURI(String uri, String defaultPrefix);
  +
       /**
  -     * Return the current message
  -     */ 
  -    public Message getCurrentMessage()
  -    {
  -        if (msgContext == null)
  -            return null;
  -        return msgContext.getCurrentMessage();
  -    }
  +     * Register prefix for the indicated uri
  +     * @param prefix
  +     * @param uri is the namespace uri
  +     */
  +    public void registerPrefixForURI(String prefix, String uri);
   
       /**
  -     * Get a prefix for the given namespace URI.  If one has already been
  -     * defined in this serialization, use that.  Otherwise, map the passed
  -     * default prefix to the URI, and return that.  If a null default prefix
  -     * is passed, use one of the form "ns<num>"
  -     */ 
  -    public String getPrefixForURI(String uri, String defaultPrefix)
  -    {
  -        if ((uri == null) || (uri.equals("")))
  -            return null;
  -
  -        String prefix = nsStack.getPrefix(uri);
  -
  -        if (prefix == null && uri.equals(Constants.URI_SOAP_ENC)) {
  -            prefix = Constants.NSPREFIX_SOAP_ENC;
  -            registerPrefixForURI(prefix, uri);
  -        }
  -
  -        if (prefix == null) {
  -            if (defaultPrefix == null) {
  -                prefix = "ns" + lastPrefixIndex++;
  -            } else {
  -                prefix = defaultPrefix;
  -            }
  -            registerPrefixForURI(prefix, uri);
  -        }
  -
  -        return prefix;
  -    }
  -
  -    public void registerPrefixForURI(String prefix, String uri)
  -    {
  -        if (category.isDebugEnabled()) {
  -            category.debug(JavaUtils.getMessage("register00", prefix, uri));
  -        }
  -
  -        if ((uri != null) && (prefix != null)) {
  -            nsStack.add(uri, prefix);
  -        }
  -    }
  -
  -    public void endPrefix(String prefix)
  -    {
  -        // Do we need to do anything here?
  -    }
  -
  -    public String qName2String(QName qName)
  -    {
  -        String prefix = getPrefixForURI(qName.getNamespaceURI());
  -        return (((prefix != null)&&(!prefix.equals(""))) ? prefix + ":" : "") +
  -               qName.getLocalPart();
  -    }
  -
  -    public QName getQNameForClass(Class cls)
  -    {
  -        return getTypeMappingRegistry().getTypeQName(cls);
  -    }
  -
  -    /**
  -     * Classes which are known to not require multi-ref.  As multi-ref
  -     * requires additional parsing overhead and not all implementations
  -     * support this, only use this function when there is a possibility
  -     * of circular references.
  -     */
  -    public boolean isPrimitive(Object value)
  -    {
  -        if (value == null) return true;
  -
  -        Class type = value.getClass();
  -        if (type.isArray()) type = type.getComponentType();
  -
  -        if (String.class.isAssignableFrom(type)) return true;
  -        if (Number.class.isAssignableFrom(type)) return true;
  -        if (Boolean.class.isAssignableFrom(type)) return true;
  -        if (Date.class.isAssignableFrom(type)) return true;
  -        if (Element.class.isAssignableFrom(type)) return true;
  -        if (Hex.class.isAssignableFrom(type)) return true;
  -        if (type.isPrimitive()) return true;
  -        return false;
  -    }
  -
  -    public void serialize(QName qName, Attributes attributes, Object value)
  -        throws IOException
  -    {
  -        if (value == null) {
  -            // If the value is null, the element is
  -            // passed with xsi:nil="true" to indicate that no object is present.
  -            //
  -            // There are three approaches that could be taken...
  -            // 1) (Currently Implemented) Use xsi:nil="true".
  -            // 2) Emit an empty element.  (This would be deserialized incorrectly.)
  -            // 3) Don't emit an element.  (This could also cause deserialization problems.)
  -            AttributesImpl attrs = new AttributesImpl();
  -            if (attributes != null)
  -                attrs.setAttributes(attributes);
  -            attrs.addAttribute(Constants.URI_2001_SCHEMA_XSI, "nil", "xsi:nil",
  -                               "CDATA", "true");
  -            startElement(qName, attrs);
  -            endElement();
  -        }
  -
  -        Message msg= getCurrentMessage();
  -        if(null != msg){
  -            //Get attachments. returns null if no attachment support.
  -            Attachments attachments= getCurrentMessage().getAttachments();
  -
  -            if( null != attachments && attachments.isAttachment(value)){
  -             //Attachment support and this is an object that should be treated as an attachment.
  -
  -             //Allow an the attachment to do its own serialization.
  -              getTypeMappingRegistry().serialize(qName, attributes, value, this);
  -              
  -              //No need to add to mulitRefs. Attachment data stream handled by
  -              // the message;
  -              return;
  -            }
  -        }
  -
  -        // If multi-reference is enabled and this object value is not a primitive
  -        // and we are not forcing serialization of the object, then generate
  -        // an element href (and store the object for subsequent outputMultiRef 
  -        // processing.
  -        if (doMultiRefs && (value != forceSer) && !isPrimitive(value)) {
  -            if (multiRefIndex == -1)
  -                multiRefValues = new HashMap();
  -
  -            String href = (String)multiRefValues.get(value);
  -            if (href == null) {
  -                multiRefIndex++;
  -                href = "id" + multiRefIndex;
  -                multiRefValues.put(value, href);
  -
  -                /** Problem - if we're in the middle of writing out
  -                 * the multi-refs and hit another level of the
  -                 * object graph, we need to make sure this object
  -                 * will get written.  For now, add it to a list
  -                 * which we'll check each time we're done with
  -                 * outputMultiRefs().
  -                 */
  -                if (outputMultiRefsFlag) {
  -                    if (secondLevelObjects == null)
  -                        secondLevelObjects = new HashSet();
  -                    secondLevelObjects.add(value);
  -                }
  -            }
  -
  -            AttributesImpl attrs = new AttributesImpl();
  -            if (attributes != null)
  -                attrs.setAttributes(attributes);
  -            attrs.addAttribute("", Constants.ATTR_HREF, "href",
  -                               "CDATA", "#" + href);
  -
  -            startElement(qName, attrs);
  -            endElement();
  -            return;
  -        }
  -
  -        // The forceSer variable is set by outputMultiRefs to force
  -        // serialization of this object via the serialize(...) call
  -        // below.  However, if the forced object contains a self-refence, we
  -        // get into an infinite loop..which is why it is set back to null
  -        // before the actual serialization.
  -        if (value == forceSer)
  -            forceSer = null;
  -
  -        getTypeMappingRegistry().serialize(qName, attributes, value, this);
  -    }
  -
  -    public void outputMultiRefs() throws IOException
  -    {
  -        if (!doMultiRefs || (multiRefValues == null))
  -            return;
  -        outputMultiRefsFlag = true;
  -        AttributesImpl attrs = new AttributesImpl();
  -        attrs.addAttribute("","","","","");
  -
  -        // explicitly state that this attribute is not a root
  -        String prefix = getPrefixForURI(Constants.URI_SOAP_ENC);
  -        String root = prefix + ":root";
  -        attrs.addAttribute(Constants.URI_SOAP_ENC, Constants.ATTR_ROOT, root, 
  -                           "CDATA", "0");
  -
  -        Iterator i = ((HashMap)multiRefValues.clone()).keySet().iterator();
  -        while (i.hasNext()) {
  -            while (i.hasNext()) {
  -                Object val = i.next();
  -                String id = (String)multiRefValues.get(val);
  -                attrs.setAttribute(0, "", Constants.ATTR_ID, "id", "CDATA",
  -                                   id);
  -                forceSer = val;
  -                serialize(new QName("","multiRef"), attrs, val);
  -            }
  -
  -            if (secondLevelObjects != null) {
  -                i = secondLevelObjects.iterator();
  -                secondLevelObjects = null;
  -            }
  -        }
  -        forceSer = null;
  -        outputMultiRefsFlag = false;
  -    }
  -
  -    public void startElement(QName qName, Attributes attributes)
  -        throws IOException
  -    {
  -        if (category.isDebugEnabled()) {
  -            category.debug(JavaUtils.getMessage("startElem00",
  -                    "[" + qName.getNamespaceURI() + "]:" + qName.getLocalPart()));
  -        }
  -
  -        if (startOfDocument && sendXMLDecl) {
  -            writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
  -            startOfDocument = false;
  -        }
  -
  -        if (writingStartTag) {
  -            writer.write(">");
  -            if (pretty) writer.write("\n");
  -            indent++;
  -        }
  -
  -        if (pretty) for (int i=0; i<indent; i++) writer.write(' ');
  -        String elementQName = qName2String(qName);
  -        writer.write("<");
  -
  -        writer.write(elementQName);
  -
  -        if (attributes != null) {
  -            for (int i = 0; i < attributes.getLength(); i++) {
  -                String qname = attributes.getQName(i);
  -                writer.write(" ");
  -
  -                String prefix = "";
  -                String uri = attributes.getURI(i);
  -                if (uri != null && !uri.equals("")) {
  -                    if (qname.equals("")) {
  -                        // If qname isn't set, generate one
  -                        prefix = getPrefixForURI(uri);
  -                    } else {
  -                        // If it is, make sure the prefix looks reasonable.
  -                        int idx = qname.indexOf(':');
  -                        if (idx > -1) {
  -                            prefix = qname.substring(0, idx);
  -                            prefix = getPrefixForURI(uri,
  -                                                     prefix);
  -                        }
  -                    }
  -                    if (!prefix.equals("")) {
  -                        qname = prefix + ":" + attributes.getLocalName(i);
  -                    } else {
  -                        qname = attributes.getLocalName(i);
  -                    }
  -                } else {
  -                    qname = attributes.getLocalName(i);
  -                    if(qname == null)
  -                        qname = attributes.getQName(i);
  -                }
  -
  -                writer.write(qname);
  -                writer.write("=\"");
  -                writer.write(XMLUtils.xmlEncodeString(attributes.getValue(i)));
  -                writer.write("\"");
  -            }
  -        }
  -
  -        ArrayList currentMappings = nsStack.peek();
  -        for (int i = 0; i < currentMappings.size(); i++) {
  -            Mapping map = (Mapping)currentMappings.get(i);
  -            writer.write(" xmlns");
  -            if (!map.getPrefix().equals("")) {
  -                writer.write(":");
  -                writer.write(map.getPrefix());
  -            }
  -            writer.write("=\"");
  -            writer.write(map.getNamespaceURI());
  -            writer.write("\"");
  -        }
  -
  -        writingStartTag = true;
  -
  -        elementStack.push(elementQName);
  -        nsStack.push();
  -
  -        writer.flush();
  -        onlyXML=true;
  -    }
  -
  -    /**
  -     * Convenience method for writing an element with no structure inside it.
  -     * (this could be optimzed later to share logic with startElement())
  -     *
  -     * @param qName the qualified name of the new element
  -     * @param attributes any attributes which should be written on the element
  -     * @exception IOException if there is any trouble
  -     */
  -    public void writeElement(QName qName, Attributes attributes)
  -        throws IOException
  -    {
  -        startElement(qName, attributes);
  -        endElement();
  -    }
  -
  -    public void endElement()
  -        throws IOException
  -    {
  -        String elementQName = (String)elementStack.pop();
  -
  -        if (category.isDebugEnabled()) {
  -            category.debug(JavaUtils.getMessage("endElem00", "" + elementQName));
  -        }
  -
  -        nsStack.pop();
  -        nsStack.peek().clear();
  -
  -        if (writingStartTag) {
  -            writer.write("/>");
  -            if (pretty) writer.write("\n");
  -            writingStartTag = false;
  -            return;
  -        }
  -
  -        if (onlyXML) {
  -            indent--;
  -            if (pretty) for (int i=0; i<indent; i++) writer.write(' ');
  -        }
  -        writer.write("</");
  -        writer.write(elementQName);
  -        writer.write('>');
  -        if (pretty) if (indent>0) writer.write('\n');
  -        writer.flush();
  -        onlyXML=true;
  -    }
  -
  -    public void writeChars(char [] p1, int p2, int p3)
  -        throws IOException
  -    {
  -        if (writingStartTag) {
  -            writer.write(">");
  -            writingStartTag = false;
  -        }
  -        writeSafeString(String.valueOf(p1,p2,p3));
  -        writer.flush();
  -        onlyXML=false;
  -    }
  -
  -    public void writeString(String string)
  -        throws IOException
  -    {
  -        if (writingStartTag) {
  -            writer.write(">");
  -            writingStartTag = false;
  -        }
  -        writer.write(string);
  -        writer.flush();
  -        onlyXML=false;
  -    }
  -
  -    public void writeSafeString(String string)
  -        throws IOException
  -    {
  -        writeString(XMLUtils.xmlEncodeString(string));
  -    }
  -
  -    /** Output a DOM representation to a SerializationContext
  -     */
  -    public void writeDOMElement(Element el)
  -        throws IOException
  -    {
  -        AttributesImpl attributes = null;
  -        NamedNodeMap attrMap = el.getAttributes();
  -
  -        if (attrMap.getLength() > 0) {
  -            attributes = new AttributesImpl();
  -            for (int i = 0; i < attrMap.getLength(); i++) {
  -                Attr attr = (Attr)attrMap.item(i);
  -                String tmp = attr.getNamespaceURI();
  -                if ( tmp != null && tmp.equals(Constants.NS_URI_XMLNS) ) {
  -                    String prefix = attr.getLocalName();
  -                    if (prefix != null) {
  -                        if (prefix.equals("xmlns"))
  -                            prefix = "";
  -                        String nsURI = attr.getValue();
  -                        registerPrefixForURI(prefix, nsURI);
  -                    }
  -                    continue;
  -                }
  -
  -                attributes.addAttribute(attr.getNamespaceURI(),
  -                                        attr.getLocalName(),
  -                                        attr.getName(),
  -                                        "CDATA", attr.getValue());
  -            }
  -        }
  -
  -        String namespaceURI = el.getNamespaceURI();
  -        String localPart = el.getLocalName();
  -        if(namespaceURI == null || namespaceURI.length()==0)
  -            localPart = el.getNodeName();
  -        QName qName = new QName(namespaceURI, localPart);
  -
  -        startElement(qName, attributes);
  -
  -        NodeList children = el.getChildNodes();
  -        for (int i = 0; i < children.getLength(); i++) {
  -            Node child = children.item(i);
  -            if (child instanceof Element) {
  -                writeDOMElement((Element)child);
  -            } else if (child instanceof Text) {
  -                writeSafeString(((Text)child).getData());
  -            }
  -        }
  +     * Get the current message.
  +     * @return Message
  +     */
  +    public Message getCurrentMessage();
   
  -        endElement();
  -    }
  +    /** 
  +     * Convert QName to a string of the form <prefix>:<localpart>
  +     * @param QName
  +     * @return prefixed qname representation for serialization.
  +     */
  +    public String qName2String(QName qName);
   
  +    /**
  +     * Get the QName associated with the specified class.
  +     * @param Class of an object requiring serialization.
  +     * @return appropriate QName associated with the class.
  +     */
  +    public QName getQNameForClass(Class cls);
  +
  +    /**
  +     * Indicates whether the object should be interpretted as a primitive
  +     * for the purposes of multi-ref processing.  A primitive value
  +     * is serialized directly instead of using id/href pairs.  Thus 
  +     * primitive serialization/deserialization is slightly faster.
  +     * @param value to be serialized
  +     * @param javaType is the "real" java type of value.  Used to distinguish
  +     * between java primitives and their wrapper classes.
  +     * @return true/false
  +     */
  +    public boolean isPrimitive(Object value, Class javaType);
  +
  +    /**
  +     * The serialize method uses hrefs to reference all non-primitive
  +     * values.  These values are stored and serialized by calling
  +     * outputMultiRefs after the serialize method completes.
  +     */
  +    public void outputMultiRefs() throws IOException;
  +
  +    /**
  +     * Writes (using the Writer) the start tag for element QName along with the
  +     * indicated attributes and namespace mappings.
  +     * @param qName is the name of the element
  +     * @param attributes are the attributes to write
  +     */
  +    public void startElement(QName qName, Attributes attributes) throws IOException;
  +
  +    /**
  +     * Writes the end element tag for the open element.
  +     **/
  +    public void endElement()  throws IOException;
  +
  +    /**
  +     * Convenience operation to write out (to Writer) the characters
  +     * in p1 starting at index p2 for length p3.
  +     * @param p1 character array to write
  +     * @param p2 starting index in array
  +     * @param p3 length to write
  +     */
  +    public void writeChars(char [] p1, int p2, int p3) throws IOException;;
  +
  +    /**
  +     * Convenience operation to write out (to Writer) the String
  +     * @param string is the String to write.
  +     */
  +    public void writeString(String string) throws IOException;
  +
  +    /**
  +     * Convenience operation to write out (to Writer) the String
  +     * properly encoded with xml entities (like &amp)
  +     * @param string is the String to write.
  +     */
  +    public void writeSafeString(String string) throws IOException;
  +
  +    /** 
  +     * Output a DOM representation to a SerializationContext
  +     * @param el is a DOM Element
  +     */
  +    public void writeDOMElement(Element el) throws IOException;
  +                      
   }
  +
  +
  
  
  
  1.14      +25 -8     xml-axis/java/src/org/apache/axis/encoding/Serializer.java
  
  Index: Serializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/Serializer.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Serializer.java	30 Oct 2001 16:46:37 -0000	1.13
  +++ Serializer.java	26 Jan 2002 02:40:33 -0000	1.14
  @@ -10,7 +10,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in
  @@ -18,7 +18,7 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:  
  + *    if any, must include the following acknowledgment:
    *       "This product includes software developed by the
    *        Apache Software Foundation (http://www.apache.org/)."
    *    Alternately, this acknowledgment may appear in the software itself,
  @@ -26,7 +26,7 @@
    *
    * 4. The names "Axis" and "Apache Software Foundation" must
    *    not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  + *    software without prior written permission. For written
    *    permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  @@ -53,21 +53,38 @@
    * <http://www.apache.org/>.
    */
   
  +
   package org.apache.axis.encoding;
   
  -//import org.apache.axis.message.Message;
  -//import org.apache.axis.message.MessageElement;
  -//import org.apache.axis.utils.NSStack;
   import org.xml.sax.Attributes;
   
   import javax.xml.rpc.namespace.QName;
   import java.io.IOException;
   
   /**
  - * @author James Snell (jasnell@us.ibm.com)
  + * This interface describes the AXIS Serializer.
  + * An Axis compliant Serializer must provide one or more 
  + * of the following methods:
  + *
  + * public <constructor>(Class javaType, QName xmlType)
  + * public <constructor>()
  + *
  + * This will allow for construction of generic factories that introspect the class 
  + * to determine how to construct a deserializer.
  + * The xmlType, javaType arguments are filled in with the values known by the factory. 
    */
  -public interface Serializer extends java.io.Serializable { 
  +public interface Serializer extends javax.xml.rpc.encoding.Serializer {
  +    /**
  +     * Serialize an element named name, with the indicated attributes 
  +     * and value.  
  +     * @param name is the element name
  +     * @param attributes are the attributes...serialize is free to add more.
  +     * @param value is the value
  +     * @param context is the SerializationContext
  +     */
       public void serialize(QName name, Attributes attributes,
                             Object value, SerializationContext context)
           throws IOException;
   }
  +
  +
  
  
  
  1.17      +1 -1      xml-axis/java/src/org/apache/axis/encoding/ServiceDescription.java
  
  Index: ServiceDescription.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ServiceDescription.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ServiceDescription.java	30 Oct 2001 14:19:29 -0000	1.16
  +++ ServiceDescription.java	26 Jan 2002 02:40:33 -0000	1.17
  @@ -109,7 +109,7 @@
           this.serviceIsRPC = isRPC;
   
           // For RPC, default to section 5 encoding
  -        if (isRPC) encodingStyleURI = Constants.URI_SOAP_ENC;
  +        if (isRPC) encodingStyleURI = Constants.URI_CURRENT_SOAP_ENC;
       }
       
       public boolean isRPC()
  
  
  
  1.48      +12 -333   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.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- TypeMappingRegistry.java	14 Jan 2002 17:31:36 -0000	1.47
  +++ TypeMappingRegistry.java	26 Jan 2002 02:40:33 -0000	1.48
  @@ -10,7 +10,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in
  @@ -18,7 +18,7 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:  
  + *    if any, must include the following acknowledgment:
    *       "This product includes software developed by the
    *        Apache Software Foundation (http://www.apache.org/)."
    *    Alternately, this acknowledgment may appear in the software itself,
  @@ -26,7 +26,7 @@
    *
    * 4. The names "Axis" and "Apache Software Foundation" must
    *    not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  + *    software without prior written permission. For written
    *    permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  @@ -53,340 +53,19 @@
    * <http://www.apache.org/>.
    */
   
  -package org.apache.axis.encoding;
  -
  -import org.apache.axis.Constants;
  -import org.apache.axis.deployment.wsdd.WSDDConstants;
  -import org.apache.axis.utils.JavaUtils;
  -import org.w3c.dom.Document;
  -import org.w3c.dom.Element;
  -import org.xml.sax.Attributes;
  -import org.xml.sax.helpers.AttributesImpl;
   
  -import javax.xml.rpc.namespace.QName;
  -import java.beans.IntrospectionException;
  -import java.io.IOException;
  -import java.io.PrintStream;
  -import java.io.Serializable;
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -import java.util.ArrayList;
  +package org.apache.axis.encoding;
   
   /**
  - * @author James Snell (jasnell@us.ibm.com)
  - * @author Sam Ruby (rubys@us.ibm.com)
  + * This interface describes the AXIS TypeMappingRegistry.
    */
  -public class TypeMappingRegistry implements Serializer { 
  -    /**
  -     * Default constructor (transient registry)
  -     */
  -    public TypeMappingRegistry() {}
  -
  -    static class SerializerDescriptor implements Serializable {
  -        QName typeQName;
  -        Serializer serializer;
  -        SerializerDescriptor(QName typeQName, Serializer serializer)
  -        {
  -            this.typeQName = typeQName;
  -            this.serializer = serializer;
  -        }
  -    }
  -
  -    static class DeserializerDescriptor implements Serializable {
  -        Class cls;
  -        DeserializerFactory factory;
  -        DeserializerDescriptor(Class cls, DeserializerFactory factory)
  -           throws IntrospectionException
  -        {
  -            this.cls = cls;
  -            this.factory = factory;
  -            factory.setJavaClass(cls);
  -        }
  -    }
  -    
  -    TypeMappingRegistry parent = null;
  -    Hashtable s;
  -    Hashtable d;
  -    
  -    public boolean isEmpty()
  -    {
  -        return (d == null || d.isEmpty());
  -    }
  -    
  +public interface TypeMappingRegistry extends javax.xml.rpc.encoding.TypeMappingRegistry {
       /**
  -     * Define a "parent" TypeMappingRegistry that will be used to service
  -     * any requests that are not satisfied by this this instance.  This
  -     * enables a chain of TypeMappingRegistries to be employed that contain,
  -     * say, a transient set of types, followed by a persistent set of
  -     * deployed types, followed by the system defined SOAPTypes
  -     */
  -    public void setParent(TypeMappingRegistry parent) {
  -        this.parent = parent;
  -        
  -        // debug assertions: every tmr must have exactly one
  -        // SOAPTypeMappingRegistry at the top.
  -        if (parent == null)
  -            new Exception(JavaUtils.getMessage("nullParent00")).printStackTrace();
  -        if (this instanceof SOAPTypeMappingRegistry)
  -            new Exception(JavaUtils.getMessage("withParent00")).printStackTrace();
  -        for (TypeMappingRegistry t = parent; t!=null; t=t.getParent())
  -            if (t instanceof SOAPTypeMappingRegistry) return;
  -        new Exception(JavaUtils.getMessage("noParent00")).printStackTrace();
  -    }
  -
  -    public TypeMappingRegistry getParent() {
  -        return parent;
  -    }
  -
  -    public void addSerializer(Class _class,
  -                              QName qName,
  -                              Serializer serializer) {
  -        if (s == null) s = new Hashtable();
  -        if (serializer instanceof BeanSerializer) {
  -            ((BeanSerializer)serializer).setCls(_class);
  -        }
  -        s.put(_class, new SerializerDescriptor(qName, serializer));
  -    }
  -    
  -    public void addDeserializerFactory(QName qname,
  -                                       Class _class,
  -                                       DeserializerFactory deserializerFactory)
  -        throws IntrospectionException
  -    {
  -        if (d == null) d= new Hashtable();
  -        d.put(qname, new DeserializerDescriptor(_class, deserializerFactory));
  -    }
  -
  -    public Serializer getSerializer(Class _class) {
  -        if (s != null) {
  -            SerializerDescriptor desc = (SerializerDescriptor)s.get(_class);
  -            if (desc != null) return desc.serializer;
  -        }
  -        if (parent != null) return parent.getSerializer(_class);
  -        return null;
  -    }
  -    
  -    public QName getTypeQName(Class _class) {
  -        if (s != null) {
  -            SerializerDescriptor desc = (SerializerDescriptor)s.get(_class);
  -            if (desc != null) return desc.typeQName;
  -        }
  -        if (parent != null) return parent.getTypeQName(_class);
  -        return null;
  -    }
  -    
  -    public Class getClassForQName(QName type) {
  -        if (d != null) {
  -            DeserializerDescriptor desc = (DeserializerDescriptor)d.get(type);
  -            if (desc != null) return desc.cls;
  -        }
  -        if (parent != null) return parent.getClassForQName(type);
  -        return null;
  -    }
  -    
  -    public Deserializer getDeserializer(QName qname) {
  -        if (qname == null)
  -            return null;
  -        
  -        if (d != null) {
  -            DeserializerDescriptor desc = (DeserializerDescriptor)d.get(qname);
  -            if ((desc != null) && (desc.factory != null))
  -               return desc.factory.getDeserializer();
  -        }
  -        if (parent != null) return parent.getDeserializer(qname);
  -        return null;
  -    }
  -    
  -    public void removeSerializer(Class _class) {
  -        if (s != null) s.remove(_class);
  -    }
  -    
  -    public void removeDeserializer(QName qname) {
  -        if (d != null) d.remove(qname);
  -    }
  -    
  -    public boolean hasSerializer(Class _class) {
  -        if (s != null && s.containsKey(_class)) return true;
  -        if (parent != null) return parent.hasSerializer(_class);
  -        return false;
  -    }
  -    
  -    public boolean hasDeserializer(QName qname) {
  -        if (d != null && d.containsKey(qname)) return true;
  -        if (parent != null) return parent.hasDeserializer(qname);
  -        return false;
  -    }
  -    
  -    public Attributes setTypeAttribute(Attributes attributes, QName type,
  -                                       SerializationContext context)
  -    {
  -        if (type == null ||
  -            !context.shouldSendXSIType() ||
  -            ((attributes != null) &&
  -             (attributes.getIndex(Constants.URI_CURRENT_SCHEMA_XSI,
  -                                "type") != -1)))
  -            return attributes;
  -        
  -        AttributesImpl attrs = new AttributesImpl();
  -        if (attributes != null)
  -            attrs.setAttributes(attributes);
  -        
  -        String prefix = context.
  -                           getPrefixForURI(Constants.URI_CURRENT_SCHEMA_XSI,
  -                                           "xsi");
  -
  -        attrs.addAttribute(Constants.URI_CURRENT_SCHEMA_XSI,
  -                           "type",
  -                           prefix + ":type",
  -                           "CDATA", context.qName2String(type));
  -        return attrs;
  -    }
  -    
  -    public void serialize(QName name, Attributes attributes,
  -                          Object value, SerializationContext context)
  -        throws IOException
  -    {
  -        if (value != null) {
  -            Serializer  ser     = null ;
  -            Class       _class  = value.getClass();
  -
  -            // Use an ArrayList and remove(0) because it MUST be 
  -            // first-in-first-out
  -            ArrayList  classes = null;
  -            
  -            while( _class != null ) {
  -                if ( (ser = getSerializer(_class)) != null ) break ;
  -                if ( classes == null ) classes = new ArrayList();
  -                Class[] ifaces = _class.getInterfaces();
  -                for (int i = 0 ; i < ifaces.length ; i++ ) 
  -                    classes.add( ifaces[i] );
  -                _class = _class.getSuperclass();
  -                
  -                // Add any non-null (and non-Object) class.  We skip
  -                // the Object class because if we reach that then
  -                // there's an error and this error message return 
  -                // here is better than the one returned by the
  -                // ObjSerializer.
  -                if ( _class != null &&
  -                        !_class.getName().equals("java.lang.Object")) 
  -                    classes.add( _class );
  -                
  -                _class = (!classes.isEmpty()) ? (Class) classes.remove( 0 ) :
  -                            null;
  -            }
  -
  -            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));
  -        }
  -        // !!! Write out a generic null, or get type info from somewhere else?
  -    }
  -    
  -    public void dump(PrintStream out, String header) {
  -        out.println(header);
  -        out.println("  Deserializers:");
  -        if (d != null) {
  -            java.util.Enumeration e = d.keys();
  -            while (e.hasMoreElements()) {
  -                Object key = e.nextElement();
  -                DeserializerDescriptor desc = (DeserializerDescriptor)d.get(key);
  -                String classname = (desc.cls != null) ? desc.cls.getName() : "null";
  -                out.println("    " + key + " => " + classname);
  -            }
  -        }
  -        if (parent != null)
  -            parent.dump(out, "Parent");
  -    }
  -
  -    public void dumpToSerializationContext(SerializationContext ctx)
  -      throws IOException
  -    {
  -        if (d == null) {
  -            return;
  -        }
  -        
  -        Enumeration enum = d.keys();
  -        while (enum.hasMoreElements()) {
  -            QName typeQName = (QName)enum.nextElement();
  -            DeserializerDescriptor desc = 
  -                                    (DeserializerDescriptor)d.get(typeQName);
  -            if (desc.cls == null)
  -                continue;
  -
  -            AttributesImpl attrs = new AttributesImpl();
  -            attrs.addAttribute("", "qname", "qname",
  -                               "CDATA", ctx.qName2String(typeQName));
  -            attrs.addAttribute("", "languageSpecificType",
  -                               "languageSpecificType",
  -                               "CDATA", "java:" + desc.cls.getName());
  -
  -            QName elementQName;
  -
  -            if (desc.factory.getClass() ==
  -                    BeanSerializer.BeanDeserFactory.class) {
  -                elementQName = WSDDConstants.BEANMAPPING_QNAME;
  -            } else {
  -                elementQName = WSDDConstants.TYPE_QNAME;
  -
  -                String dser = desc.factory.getClass().getName();
  -                attrs.addAttribute("", "deserializer", "deserializer",
  -                                   "CDATA", dser);
  -
  -                SerializerDescriptor serDesc =
  -                        (SerializerDescriptor)s.get(desc.cls);
  -                if (serDesc != null) {
  -                    attrs.addAttribute("", "serializer", "serializer",
  -                                       "CDATA",
  -                                       serDesc.serializer.
  -                                                    getClass().getName());
  -                }
  -            }
  -
  -            ctx.startElement(elementQName, attrs);
  -            ctx.endElement();
  -        }
  -    }
  -
  -    public void dumpToElement(Element root)
  -    {
  -        if ((d == null) || (parent == null)) {
  -            return;
  -        }
  -
  -        Document doc = root.getOwnerDocument();
  -        
  -        Enumeration enum = d.keys();
  -        while (enum.hasMoreElements()) {
  -            QName typeQName = (QName)enum.nextElement();
  -            DeserializerDescriptor desc = 
  -                                   (DeserializerDescriptor)d.get(typeQName);
  -            if (desc.cls == null)
  -                continue;
  -            
  -            Element mapEl = doc.createElementNS("", "typeMapping");
  +     * Return the default TypeMapping
  +     * (According to the JAX-RPC rep, this will be in javax.xml.rpc.encoding.TypeMappingRegistry for version 0.7)
  +     * @return TypeMapping or null
  +     **/
  +    public javax.xml.rpc.encoding.TypeMapping getDefaultTypeMapping();
  +}
   
  -            mapEl.setAttribute("type", "ns:" + typeQName.getLocalPart());
  -            mapEl.setAttribute("xmlns:ns", typeQName.getNamespaceURI());
  -            
  -            mapEl.setAttribute("classname", desc.cls.getName());
  -            
  -            String dser = desc.factory.getClass().getName();
  -            mapEl.setAttribute("deserializerFactory", dser);
  -            
  -            SerializerDescriptor serDesc =
  -                                      (SerializerDescriptor)s.get(desc.cls);
  -            if (serDesc != null) {
  -                mapEl.setAttribute("serializer", serDesc.serializer.
  -                                                      getClass().getName());
  -            }
   
  -            root.appendChild(mapEl);
  -        }
  -    }
  -}
  
  
  
  1.13      +28 -29    xml-axis/java/src/org/apache/axis/encoding/XMLType.java
  
  Index: XMLType.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/XMLType.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- XMLType.java	4 Jan 2002 22:30:03 -0000	1.12
  +++ XMLType.java	26 Jan 2002 02:40:33 -0000	1.13
  @@ -66,45 +66,44 @@
   
   
   public class XMLType {
  -    public static final QName XSD_STRING = new QName(Constants.URI_CURRENT_SCHEMA_XSD, "string");
  -    public static final QName XSD_BOOLEAN = new QName(Constants.URI_CURRENT_SCHEMA_XSD, "boolean");
  -    public static final QName XSD_DOUBLE = new QName(Constants.URI_CURRENT_SCHEMA_XSD, "double");
  -    public static final QName XSD_FLOAT = new QName(Constants.URI_CURRENT_SCHEMA_XSD, "float");
  -    public static final QName XSD_INT = new QName(Constants.URI_CURRENT_SCHEMA_XSD, "int");
  -    public static final QName XSD_LONG = new QName(Constants.URI_CURRENT_SCHEMA_XSD, "long");
  -    public static final QName XSD_SHORT = new QName(Constants.URI_CURRENT_SCHEMA_XSD, "short");
  -    public static final QName XSD_BYTE = new QName(Constants.URI_CURRENT_SCHEMA_XSD, "byte");
  -    public static final QName XSD_DECIMAL = new QName(Constants.URI_CURRENT_SCHEMA_XSD, "decimal");
  -    public static final QName XSD_BASE64 = new QName(Constants.URI_2001_SCHEMA_XSD, "base64Binary");
  -//    public static final QName XSD_HEXBIN = new QName(Constants.URI_2001_SCHEMA_XSD, "hexBinary");
  -    public static final QName XSD_ANYTYPE = new QName(Constants.URI_2001_SCHEMA_XSD, "anyType");
  -    public static final QName SOAP_BASE64 = new QName(Constants.URI_SOAP_ENC, "base64");
  +    // Rich Scheuerle Note:  Shouldn't this class be phased out...The constants in Constants
  +    // should be used.
  +    public static final QName XSD_STRING = Constants.XSD_STRING;
  +    public static final QName XSD_BOOLEAN = Constants.XSD_BOOLEAN;
  +    public static final QName XSD_DOUBLE = Constants.XSD_DOUBLE;
  +    public static final QName XSD_FLOAT = Constants.XSD_FLOAT;
  +    public static final QName XSD_INT = Constants.XSD_INT;
  +    public static final QName XSD_LONG = Constants.XSD_LONG;
  +    public static final QName XSD_SHORT = Constants.XSD_SHORT;
  +    public static final QName XSD_BYTE = Constants.XSD_BYTE;
  +    public static final QName XSD_DECIMAL = Constants.XSD_DECIMAL;
  +    public static final QName XSD_BASE64 = Constants.XSD_BASE64;
  +    public static final QName XSD_ANYTYPE = Constants.XSD_ANYTYPE;
  +    public static final QName SOAP_BASE64 = Constants.SOAP_BASE64;
   
  -    public static final QName SOAP_STRING = new QName(Constants.URI_SOAP_ENC, "string");
  -    public static final QName SOAP_BOOLEAN = new QName(Constants.URI_SOAP_ENC, "boolean");
  -    public static final QName SOAP_DOUBLE = new QName(Constants.URI_SOAP_ENC, "double");
  -    public static final QName SOAP_FLOAT = new QName(Constants.URI_SOAP_ENC, "float");
  -    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_BYTE = new QName(Constants.URI_SOAP_ENC, "byte");
  -    public static final QName SOAP_ARRAY = new QName(Constants.URI_SOAP_ENC, "Array");
  +    public static final QName SOAP_STRING = Constants.SOAP_STRING;
  +    public static final QName SOAP_BOOLEAN = Constants.SOAP_BOOLEAN;
  +    public static final QName SOAP_DOUBLE = Constants.SOAP_DOUBLE;
  +    public static final QName SOAP_FLOAT = Constants.SOAP_FLOAT;
  +    public static final QName SOAP_INT = Constants.SOAP_INT;
  +    public static final QName SOAP_LONG = Constants.SOAP_LONG;
  +    public static final QName SOAP_SHORT = Constants.SOAP_SHORT;
  +    public static final QName SOAP_BYTE = Constants.SOAP_BYTE;
  +    public static final QName SOAP_ARRAY = Constants.SOAP_ARRAY;
   
  -    public static final QName TYPE_MAP = new QName("http://xml.apache.org/xml-soap", "Map");
  -    public static final QName TYPE_ELEMENT = new QName("http://xml.apache.org/xml-soap", "Element");
  +    public static final QName SOAP_MAP = Constants.SOAP_MAP;
  +    public static final QName SOAP_ELEMENT = Constants.SOAP_ELEMENT;                                
   
       public static       QName XSD_DATE;
       
       static {
           if (Constants.URI_CURRENT_SCHEMA_XSD.equals(
                   Constants.URI_1999_SCHEMA_XSD))
  -            XSD_DATE =
  -                    new QName(Constants.URI_CURRENT_SCHEMA_XSD, "timeInstant");
  +            XSD_DATE = Constants.XSD_DATE2;
           else if (Constants.URI_CURRENT_SCHEMA_XSD.equals(
                   Constants.URI_2000_SCHEMA_XSD))
  -            XSD_DATE =
  -                    new QName(Constants.URI_CURRENT_SCHEMA_XSD, "timeInstant");
  +            XSD_DATE = Constants.XSD_DATE3;
           else
  -            XSD_DATE = new QName(Constants.URI_CURRENT_SCHEMA_XSD, "dateTime");
  +            XSD_DATE = Constants.XSD_DATE;
       }
   }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/Callback.java
  
  Index: Callback.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding;
  
  import org.xml.sax.SAXException;
  
  public interface Callback
  {
      public void setValue(Object value, Object hint) throws SAXException;
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/CallbackTarget.java
  
  Index: CallbackTarget.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding;
  
  import org.xml.sax.SAXException;
  import org.apache.axis.encoding.Deserializer;
  
  // Target is a Callback.  The set method invokes one of the setValue methods
  // of the callback using the hing.  The CallbackTarget
  // is used in situations when the Deserializer is expecting multiple values and cannot
  // be considered complete until all values are received.
  // (example is an ArrayDeserializer).
  public class CallbackTarget implements Target {
      public Callback target;
      public Object hint;
      public CallbackTarget(Callback target, Object hint)
      {
          this.target = target;
          this.hint = hint;
      }
      
      public void set(Object value) throws SAXException {
          target.setValue(value, hint);
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java
  
  Index: DefaultTypeMappingImpl.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding;
  
  import org.apache.axis.Constants;
  
  import javax.xml.rpc.namespace.QName;
  import javax.xml.rpc.JAXRPCException;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  
  import org.apache.axis.encoding.ser.ArraySerializerFactory;
  import org.apache.axis.encoding.ser.ArrayDeserializerFactory;
  import org.apache.axis.encoding.ser.BeanSerializerFactory;
  import org.apache.axis.encoding.ser.BeanDeserializerFactory;
  import org.apache.axis.encoding.ser.DateSerializerFactory;
  import org.apache.axis.encoding.ser.DateDeserializerFactory;
  import org.apache.axis.encoding.ser.Base64SerializerFactory;
  import org.apache.axis.encoding.ser.Base64DeserializerFactory;
  import org.apache.axis.encoding.ser.MapSerializerFactory;
  import org.apache.axis.encoding.ser.MapDeserializerFactory;
  import org.apache.axis.encoding.ser.HexSerializerFactory;
  import org.apache.axis.encoding.ser.HexDeserializerFactory;
  import org.apache.axis.encoding.ser.ElementSerializerFactory;
  import org.apache.axis.encoding.ser.ElementDeserializerFactory;
  import org.apache.axis.encoding.ser.VectorDeserializerFactory;
  import org.apache.axis.encoding.ser.SimpleDeserializerFactory;
  import org.apache.axis.encoding.ser.SimplePrimitiveSerializerFactory;
  import org.apache.axis.encoding.ser.SimpleNonPrimitiveSerializerFactory;
  import java.util.Vector;
  import java.util.Hashtable;
  import java.util.List;
  
  /**
   * @author Rich Scheuerle (scheu@us.ibm.com)
   * 
   * This is the implementation of the axis Default TypeMapping (which extends
   * the JAX-RPC TypeMapping interface).
   * 
   * A TypeMapping is obtained from the singleton TypeMappingRegistry using
   * the namespace of the webservice.  The TypeMapping contains the tuples
   * {Java type, SerializerFactory, DeserializerFactory, Type QName)
   *
   * So if you have a Web Service with the namespace "XYZ", you call 
   * the TypeMappingRegistry.getTypeMapping("XYZ").
   *
   * The wsdl in your web service will use a number of types.  The tuple
   * information for each of these will be accessed via the TypeMapping.
   *
   * Because every web service uses the soap, schema, wsdl primitives, we could 
   * pre-populate the TypeMapping with these standard tuples.  Instead, if requested
   * namespace/class matches is not found in the TypeMapping but matches one these
   * known primitives, the request is delegated to this Default TypeMapping.
   * 
   */
  public class DefaultTypeMappingImpl extends TypeMappingImpl { 
      
      private static DefaultTypeMappingImpl tm = null;
      /**
       * Construct TypeMapping
       */
      public static TypeMapping create() {
          if (tm == null) {
              tm = new DefaultTypeMappingImpl();
          }
          return tm;
      }
  
      private DefaultTypeMappingImpl() {
          super(null);
          delegateIfNotFound = false;
  
          // The XSD Primitives are mapped to java primitives.
          // The corresponding SOAP-ENC primitives are mapped to the wrapper classes.
          myRegister(Constants.XSD_BOOLEAN,    boolean.class,              null, null);
          myRegister(Constants.XSD_DOUBLE,     double.class,               null, null);
          myRegister(Constants.XSD_FLOAT,      float.class,                null, null);
          myRegister(Constants.XSD_INT,        int.class,                  null, null);
          myRegister(Constants.XSD_LONG,       long.class,                 null, null);
          myRegister(Constants.XSD_SHORT,      short.class,                null, null);
          myRegister(Constants.XSD_BYTE,       byte.class,                 null, null);
          myRegister(Constants.XSD_STRING,     java.lang.String.class,     null, null);
          myRegister(Constants.XSD_INTEGER,    java.math.BigInteger.class, null, null);
          myRegister(Constants.XSD_DECIMAL,    java.math.BigDecimal.class, null, null);
          myRegister(Constants.XSD_QNAME,      javax.xml.rpc.namespace.QName.class,
                     new BeanSerializerFactory(javax.xml.rpc.namespace.QName.class,
                                               Constants.XSD_QNAME),
                     new BeanDeserializerFactory(javax.xml.rpc.namespace.QName.class,
                                                 Constants.XSD_QNAME));
          myRegister(Constants.XSD_ANYTYPE,    java.lang.Object.class,     null, null);
          myRegister(Constants.XSD_DATE,       java.util.Date.class,                           
                     new DateSerializerFactory(java.util.Date.class,Constants.XSD_DATE),
                     new DateDeserializerFactory(java.util.Date.class,Constants.XSD_DATE));
          myRegister(Constants.XSD_DATE2,      java.util.Date.class,                           
                     new DateSerializerFactory(java.util.Date.class, Constants.XSD_DATE2),
                     new DateDeserializerFactory(java.util.Date.class, Constants.XSD_DATE2));
          myRegister(Constants.XSD_DATE3,      java.util.Date.class,                           
                     new DateSerializerFactory(java.util.Date.class, Constants.XSD_DATE3),
                     new DateDeserializerFactory(java.util.Date.class, Constants.XSD_DATE3));
          myRegister(Constants.XSD_BASE64,     byte[].class,                                   
                     new Base64SerializerFactory(),
                     new Base64DeserializerFactory());
          myRegister(Constants.XSD_HEXBIN,     Hex.class,   
                     new HexSerializerFactory(),
                     new HexDeserializerFactory());
  
          // Use the Map Serialization for both Hashtables and HashMap objects
          myRegister(Constants.SOAP_MAP,       java.util.HashMap.class,    
                     new MapSerializerFactory(java.util.HashMap.class,Constants.SOAP_MAP),
                     new MapDeserializerFactory(java.util.HashMap.class,Constants.SOAP_MAP));
          myRegister(Constants.SOAP_MAP,       java.util.Hashtable.class,    
                     new MapSerializerFactory(java.util.Hashtable.class,Constants.SOAP_MAP),
                     new MapDeserializerFactory(java.util.Hashtable.class,Constants.SOAP_MAP));
  
          // Use the Element Serializeration for elements
          myRegister(Constants.SOAP_ELEMENT,   org.w3c.dom.Element.class,    
                     new ElementSerializerFactory(),
                     new ElementDeserializerFactory());
          myRegister(Constants.SOAP_VECTOR,    java.util.Vector.class,             
                     null,
                     new VectorDeserializerFactory(java.util.Vector.class,Constants.SOAP_VECTOR));
  
          // All array objects automatically get associated with the SOAP_ARRAY.  There
          // is no way to do this with a hash table, so it is done directly in getTypeQName.
          // Internally the runtime uses ArrayList objects to hold arrays...which is 
          // the reason that ArrayList is associated with SOAP_ARRAY.  In addition, handle
          // all objects that implement the List interface as a SOAP_ARRAY
          myRegister(Constants.SOAP_ARRAY,     java.util.List.class,               
                     new ArraySerializerFactory(),
                     new ArrayDeserializerFactory());
          myRegister(Constants.SOAP_ARRAY,     java.util.ArrayList.class,               
                     new ArraySerializerFactory(),
                     new ArrayDeserializerFactory());
  
          myRegister(Constants.SOAP_STRING,     java.lang.String.class,     null, null); 
          myRegister(Constants.SOAP_BOOLEAN,    java.lang.Boolean.class,    null, null);
          myRegister(Constants.SOAP_DOUBLE,     java.lang.Double.class,     null, null);
          myRegister(Constants.SOAP_FLOAT,      java.lang.Float.class,      null, null);
          myRegister(Constants.SOAP_INT,        java.lang.Integer.class,    null, null);
          myRegister(Constants.SOAP_INTEGER,    java.math.BigInteger.class, null, null);
          myRegister(Constants.SOAP_DECIMAL,    java.math.BigDecimal.class, null, null);
          myRegister(Constants.SOAP_LONG,       java.lang.Long.class,       null, null);
          myRegister(Constants.SOAP_SHORT,      java.lang.Short.class,      null, null);
          myRegister(Constants.SOAP_BYTE,       java.lang.Byte.class,       null, null);
  
          // Note that a SOAP_BASE64 is mapped to a Byte[] not a byte[].  This is 
          // the reason why the array serialization is used.
          myRegister(Constants.SOAP_BASE64,     java.lang.Byte[].class,       
                     new ArraySerializerFactory(),
                     new ArrayDeserializerFactory());
      }
  
      /**
       * Construct TypeMapping for all the [xmlType, javaType] for all of the
       * known xmlType namespaces
       */   
      protected void myRegister(QName xmlType, Class javaType,
                                SerializerFactory sf, DeserializerFactory df) {
          // If the type is truly a primitive, then the serializer can
          // be shared.  Otherwise the serializers/deserializers can't be shared.
          boolean primitive = (javaType.isPrimitive() || javaType == java.lang.String.class);
  
          // If factories are not specified, use the Simple serializer/deserializer factories.
          if (sf == null && df == null) {
              if (primitive) {
                  sf = new SimplePrimitiveSerializerFactory(javaType, xmlType);
              } else {
                  sf = new SimpleNonPrimitiveSerializerFactory(javaType, xmlType);
              }
              df = new SimpleDeserializerFactory(javaType, xmlType);
          }
  
          // Register all known flavors of the namespace.
          try {
              if (xmlType.getNamespaceURI().equals(Constants.URI_CURRENT_SCHEMA_XSD)) {
                  for (int i=0; i < Constants.URIS_SCHEMA_XSD.length; i++) {
                      QName qName = new QName(Constants.URIS_SCHEMA_XSD[i], xmlType.getLocalPart());
                      register(javaType, qName, sf, df);
                  }
              }
              else if (xmlType.getNamespaceURI().equals(Constants.URI_CURRENT_SOAP_ENC)) {
                  for (int i=0; i < Constants.URIS_SOAP_ENC.length; i++) {
                      QName qName = new QName(Constants.URIS_SOAP_ENC[i], xmlType.getLocalPart());
                      register(javaType, qName, sf, df);
                  }
              }
              // Register with the specified xmlType.  This is the prefered mapping and
              // the last registered mapping wins.
              register(javaType, xmlType, sf, df);
          } catch (Exception e) {}
      }
  
      /**
       * Gets the QName for the type mapped to Class.
       * @param javaType class or type
       * @return xmlType qname or null
       */
      public QName getTypeQName(Class javaType) {
          QName xmlType = super.getTypeQName(javaType);
  
          // Can only detect arrays via code
          if (xmlType == null &&
              (javaType.isArray() ||
               javaType == List.class ||
               List.class.isAssignableFrom(javaType))) {
              xmlType = Constants.SOAP_ARRAY;
          }
          return xmlType;
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/DeserializationContextImpl.java
  
  Index: DeserializationContextImpl.java
  ===================================================================
  package org.apache.axis.encoding;
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import org.apache.axis.attachments.Attachments; 
  
  import org.apache.axis.Constants;
  import org.apache.axis.MessageContext;
  import org.apache.axis.Message;
  import org.apache.axis.message.EnvelopeBuilder;
  import org.apache.axis.message.EnvelopeHandler;
  import org.apache.axis.message.HandlerFactory;
  import org.apache.axis.message.IDResolver;
  import org.apache.axis.message.MessageElement;
  import org.apache.axis.message.SAX2EventRecorder;
  import org.apache.axis.message.SOAPEnvelope;
  import org.apache.axis.message.SOAPHandler;
  import org.apache.axis.utils.NSStack;
  import org.apache.axis.utils.JavaUtils;
  import org.apache.axis.utils.XMLUtils;
  import org.apache.log4j.Category;
  import org.xml.sax.Attributes;
  import org.xml.sax.InputSource;
  import org.xml.sax.Locator;
  import org.xml.sax.SAXException;
  import org.xml.sax.helpers.DefaultHandler;
  import org.apache.axis.AxisFault;
  
  import javax.xml.parsers.SAXParser;
  import javax.xml.rpc.namespace.QName;
  import javax.xml.rpc.JAXRPCException;
  
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.Stack;
  
  /** 
   * @author Glen Daniels (gdaniels@macromedia.com)
   * Re-architected for JAX-RPC Compliance by:
   * @author Rich Scheuerle (scheu@us.ibm.com)
   */
  
  public class DeserializationContextImpl extends DefaultHandler implements DeserializationContext
  {
      static Category category =
              Category.getInstance(DeserializationContextImpl.class.getName());
      
      
      private NSStack namespaces = new NSStack();
      
      private Locator locator;
                                               
      private Stack handlerStack = new Stack();
      
      private SAX2EventRecorder recorder = new SAX2EventRecorder();
      private SOAPEnvelope envelope;
      
  
      /* A map of IDs -> IDResolvers */
      private HashMap idMap;
      private LocalIDResolver localIDs;
      
      private HashMap fixups;
      
      static final SOAPHandler nullHandler = new SOAPHandler();
      
      protected MessageContext msgContext;
      
      protected HandlerFactory initialFactory;
      
      private boolean doneParsing = false;
      protected InputSource inputSource = null;
  
      private MessageElement curElement;
  
      protected int startOfMappingsPos = -1;
      
          
      /**
       * Construct Deserializer using MessageContext and EnvelopeBuilder handler
       * @param ctx is the MessageContext
       * @param initialHandler is the EnvelopeBuilder handler
       */
      public DeserializationContextImpl(MessageContext ctx, EnvelopeBuilder initialHandler)
      {
          msgContext = ctx;
          
          envelope = initialHandler.getEnvelope();
          envelope.setRecorder(recorder);
          
          pushElementHandler(new EnvelopeHandler(initialHandler));
      }
      
      /**
       * Construct Deserializer 
       * @param is is the InputSource
       * @param ctx is the MessageContext
       * @param messageType is the MessageType to construct an EnvelopeBuilder
       */
      public DeserializationContextImpl(InputSource is, MessageContext ctx, 
                                    String messageType)
      {
          EnvelopeBuilder builder = new EnvelopeBuilder(messageType);
          
          msgContext = ctx;
          
          envelope = builder.getEnvelope();
          envelope.setRecorder(recorder);
          
          pushElementHandler(new EnvelopeHandler(builder));
  
          inputSource = is;
      }
      
      /**
       * Construct Deserializer 
       * @param is is the InputSource
       * @param ctx is the MessageContext
       * @param messageType is the MessageType to construct an EnvelopeBuilder
       * @param env is the SOAPEnvelope to construct an EnvelopeBuilder
       */
      public DeserializationContextImpl(InputSource is, MessageContext ctx, 
                                    String messageType, SOAPEnvelope env)
      {
          EnvelopeBuilder builder = new EnvelopeBuilder(env, messageType);
          
          msgContext = ctx;
          
          envelope = builder.getEnvelope();
          envelope.setRecorder(recorder);
          
          pushElementHandler(new EnvelopeHandler(builder));
  
          inputSource = is;
      }
      
      /**
       * Create a parser and parse the inputSource
       */
      public void parse() throws SAXException
      {
          if (inputSource != null) {
              SAXParser parser = XMLUtils.getSAXParser();
              try {
                  parser.parse(inputSource, this);
  
                  // only release the parser for reuse if there wasn't an
                  // error.  While parsers should be reusable, don't trust
                  // parsers that died to clean up appropriately.
                  XMLUtils.releaseSAXParser(parser);
              } catch (IOException e) {
                  throw new SAXException(e);
              }
              inputSource = null;
          }
      }
  
      /**
       * Get current MessageElement
       **/
      public MessageElement getCurElement() {
          return curElement;
      }
  
      /**
       * Set current MessageElement
       **/
      public void setCurElement(MessageElement el)
      {
          curElement = el;
      }
      
      
      /**
       * Get MessageContext         
       */
      public MessageContext getMessageContext()
      {
          return msgContext;
      }
      
      /**
       * Get Envelope               
       */
      public SOAPEnvelope getEnvelope()
      {
          return envelope;
      }
      
      /**
       * Get Event Recorder         
       */
      public SAX2EventRecorder getRecorder()
      {
          return recorder;
      }
      
      /**
       * Set Event Recorder         
       */
      public void setRecorder(SAX2EventRecorder recorder)
      {
          this.recorder = recorder;
      }
  
      /**
       * Get the Namespace Mappings
       **/
      public ArrayList getCurrentNSMappings()
      {
          return (ArrayList)namespaces.peek().clone();
      }
      
      /** 
       * Get the Namespace for a particular prefix
       */
      public String getNamespaceURI(String prefix) 
      {
          if (curElement != null)
              return curElement.getNamespaceURI(prefix);
  
          return namespaces.getNamespaceURI(prefix);
      }
      
      /**
       * Construct a QName from a string of the form <prefix>:<localName>
       * @param qNameStr is the prefixed name from the xml text
       * @return QName
       */
      public QName getQNameFromString(String qNameStr)
      { 
          if (qNameStr == null)
              return null;
          
          // OK, this is a QName, so look up the prefix in our current mappings.        
          int i = qNameStr.indexOf(':');
          if (i == -1)
              return null;
          
          String nsURI = getNamespaceURI(qNameStr.substring(0, i));
          
          //System.out.println("namespace = " + nsURI);
          
          if (nsURI == null)
              return null;
          
          return new QName(nsURI, qNameStr.substring(i + 1));
      }
      
      /** 
       * Create a QName for the type of the element defined by localName and
       * namespace with the specified attributes.
       * @param namespace of the element
       * @param localName is the local name of the element
       * @param attrs are the attributes on the element
       */
      public QName getTypeFromAttributes(String namespace, String localName,
                                         Attributes attrs)
      {
          QName typeQName = null;
          
          // I am not sure why we are querying the name instead of the type?
          if (typeQName == null) {
              QName myQName = new QName(namespace, localName);
              if (myQName.equals(Constants.SOAP_ARRAY)) {
                  typeQName = Constants.SOAP_ARRAY;
              } else if (myQName.equals(Constants.SOAP_STRING)) {
                  typeQName = Constants.XSD_STRING;
              } else if (myQName.equals(Constants.SOAP_BOOLEAN)) {
                  typeQName = Constants.XSD_BOOLEAN;
              } else if (myQName.equals(Constants.SOAP_DOUBLE)) {
                  typeQName = Constants.XSD_DOUBLE;
              } else if (myQName.equals(Constants.SOAP_FLOAT)) {
                  typeQName = Constants.XSD_FLOAT;
              } else if (myQName.equals(Constants.SOAP_INT)) {
                  typeQName = Constants.XSD_INT;
              } else if (myQName.equals(Constants.SOAP_LONG)) {
                  typeQName = Constants.XSD_LONG;
              } else if (myQName.equals(Constants.SOAP_SHORT)) {
                  typeQName = Constants.XSD_SHORT;
              } else if (myQName.equals(Constants.SOAP_BYTE)) {
                  typeQName = Constants.XSD_BYTE;
              }
          }
  
          // Return with the type if the name matches one of the above primitives
          if (typeQName != null)
              return typeQName;
          
          // If no attribute information, can't continue
          if (attrs == null)
              return null;
          
          // Check for type
          String type = Constants.getValue(attrs, Constants.URI_CURRENT_SCHEMA_XSI, "type");
          
          if (type == null)
              return null;
  
          // Return the type attribute value converted to a QName
          return getQNameFromString(type);
      }
  
      /**
       * Convenenience method that returns true if the value is nil 
       * (due to the xsi:nil) attribute.
       * @param attributes are the element attributes.
       * @return true if xsi:nil is true
       */
      public boolean isNil(Attributes attrs) {
          if (attrs == null) {
              return false;
          }
          String nil = Constants.getValue(attrs, Constants.URI_CURRENT_SCHEMA_XSI, "nil");
          return (nil != null && nil.equals("true"));
      }
  
      /**
       * Convenience method to get the Deserializer for a specific
       * xmlType.
       * @param xmlType is QName for a type to deserialize
       * @return Deserializer
       */
      public final Deserializer getDeserializerForType(QName xmlType) {
          DeserializerFactory dserF = null;
          Deserializer dser = null;
          try { 
              dserF = (DeserializerFactory) getTypeMapping().getDeserializer(xmlType);
          } catch (JAXRPCException e) {
              System.out.println("!! No Factory for " + xmlType);
          }
          if (dserF != null) {
              try {
                  dser = (Deserializer) dserF.getDeserializerAs(Constants.AXIS_SAX);
              } catch (JAXRPCException e) {
                  System.out.println("!! No Deserializer for " + xmlType);
              }
          }
          return dser;
      }
      
      /** 
       * Get the TypeMapping for this DeserializationContext
       */
      public TypeMapping getTypeMapping()
      {
          return (TypeMapping) msgContext.getTypeMappingRegistry().getTypeMapping(Constants.URI_CURRENT_SOAP_ENC);
      }
      
      /**
       * Get the TypeMappingRegistry we're using.
       * @return TypeMapping or null
       */ 
      public TypeMappingRegistry getTypeMappingRegistry() {
          return (TypeMappingRegistry) msgContext.getTypeMappingRegistry();
      }
  
      /**
       * Get the MessageElement for the indicated id (where id is the #value of an href)
       * If the MessageElement has not been processed, the MessageElement will 
       * be returned.  If the MessageElement has been processed, the actual object
       * value is stored with the id and this routine will return null.
       * @param id is the value of an href attribute
       * @return MessageElement or null
       */ 
      public MessageElement getElementByID(String id)
      {
          if((idMap !=  null)) {
              IDResolver resolver = (IDResolver)idMap.get(id);
              if(resolver != null) {
                  Object ret = resolver.getReferencedObject(id);
                  if (ret instanceof MessageElement)
                      return (MessageElement)ret;
              }
          }
          
          return null;
      }
      
      /**
       * Gets the MessageElement or actual Object value associated with the href value.  
       * The return of a MessageElement indicates that the referenced element has 
       * not been processed.  If it is not a MessageElement, the Object is the
       * actual deserialized value.  
       * In addition, this method is invoked to get Object values via Attachments.
       * @param id is the value of an href attribute (or an Attachment id)
       * @return MessageElement other Object or null
       */ 
      public Object getObjectByRef(String href) {
          Object ret= null;
          if(href != null){
              if((idMap !=  null)){
                  IDResolver resolver = (IDResolver)idMap.get(href);
                  if(resolver != null)
                     ret = resolver.getReferencedObject(href);
              }
              if( null == ret && !href.startsWith("#")){
                  //Could this be an attachment?
                  Message msg= null;
                  if(null != (msg=msgContext.getCurrentMessage())){
                      Attachments attch= null;
                      if( null != (attch= msg.getAttachments())){ 
                          try{
                          ret= attch.getAttachmentByReference(href);
                          }catch(AxisFault e){};
                      }
                  }
              }
          }
  
          return ret; 
      }
      
      /**
       * Add the object associated with this id (where id is the value of an id= attribute,
       * i.e. it does not start with #).  
       * This routine is called to associate the deserialized object
       * with the id specified on the XML element.
       * @param id (id name without the #)
       * @param obj is the deserialized object for this id.
       */
      public void addObjectById(String _id, Object obj)
      {
          // The resolver uses the href syntax as the key.
          String id = "#" + _id;
          if ((idMap == null) || (id == null))
              return ;
          
          IDResolver resolver = (IDResolver)idMap.get(id);
          if (resolver == null)
              return ;
          
          resolver.addReferencedObject(id, obj);
          return;
      }
  
      /**
       * During deserialization, an element with an href=#id<int>
       * may be encountered before the element defining id=id<int> is
       * read.  In these cases, the getObjectByRef method above will
       * return null.  The deserializer is placed in a table keyed
       * by href (a fixup table). After the element id is processed,
       * the deserializer is informed of the value so that it can
       * update its target(s) with the value.
       * @param href (#id syntax)
       * @param dser is the deserializer of the element
       */
      public void registerFixup(String href, Deserializer dser)
      {
          if (fixups == null)
              fixups = new HashMap();
  
          Deserializer prev = (Deserializer) fixups.put(href, dser);
  
          // There could already be a deserializer in the fixup list
          // for this href.  If so, the easiest way to get all of the
          // targets updated is to copy the previous deserializers 
          // targets to dser.
          if (prev != null && prev != dser)
              dser.copyValueTargets(prev);
      }
      
      /**
       * Register the MessageElement with this id (where id is id= form without the #)     
       * This routine is called when the MessageElement with an id is read.
       * If there is a Deserializer in our fixup list (described above),
       * the 'fixup' deserializer is given to the MessageElement.  When the
       * MessageElement is completed, the 'fixup' deserializer is informed and
       * it can set its targets.
       * @param id (id name without the #)
       * @param elem is the MessageElement                   
       */
      public void registerElementByID(String id, MessageElement elem)
      {
          if (localIDs == null)
              localIDs = new LocalIDResolver();
          
          String absID = "#" + id;
          
          localIDs.addReferencedObject(absID, elem);
          
          registerResolverForID(absID, localIDs);
          
          if (fixups != null) {
              Deserializer dser = (Deserializer)fixups.get(absID);
              if (dser != null) {
                  elem.setFixupDeserializer(dser);
              }
          }
      }
      
      /**
       * Each id can have its own kind of resolver.  This registers a 
       * resolver for the id.
       */
      public void registerResolverForID(String id, IDResolver resolver)
      {
          if ((id == null) || (resolver == null)) {
              // ??? Throw nullPointerException?
              return;
          }
          
          if (idMap == null)
              idMap = new HashMap();
          
          idMap.put(id, resolver);
      }
      
      /**
       * Get the current position in the record.
       */
      public int getCurrentRecordPos()
      {
          if (recorder == null) return -1;
          return recorder.getLength() - 1;
      }
      
      /**
       * Get the start of the mapping position  
       */
      public int getStartOfMappingsPos()
      {
          if (startOfMappingsPos == -1) {
              return getCurrentRecordPos() + 1;
          }
          
          return startOfMappingsPos;
      }
      
      /**
       * Push the MessageElement into the recorder
       */
      public void pushNewElement(MessageElement elem)
      {
          if (recorder != null) {
              recorder.newElement(elem);
          }
          
          elem.setParent(curElement);
          curElement = elem;
      }
      
      /****************************************************************
       * Management of sub-handlers (deserializers)
       */
      
      public SOAPHandler getTopHandler()
      {
          try {
              return (SOAPHandler)handlerStack.peek();
          } catch (Exception e) {
              return null;
          }
      }
      
      public void pushElementHandler(SOAPHandler handler)
      {
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("pushHandler00", "" + handler));
          }
          
          handlerStack.push(handler);
      }
      
      /** Replace the handler at the top of the stack.
       * 
       * This is only used when we have a placeholder Deserializer
       * for a referenced object which doesn't know its type until we
       * hit the referent.
       */
      public void replaceElementHandler(SOAPHandler handler)
      {
          handlerStack.pop();
          handlerStack.push(handler);
      }
      
      public SOAPHandler popElementHandler()
      {
          if (!handlerStack.empty()) {
              SOAPHandler handler = getTopHandler();
              if (category.isDebugEnabled()) {
                  category.debug(JavaUtils.getMessage("popHandler00", "" + handler));
              }
              handlerStack.pop();
              return handler;
          } else {
              if (category.isDebugEnabled()) {
                  category.debug(JavaUtils.getMessage("popHandler00", "(null)"));
              }
              return null;
          }
      }
      
      /****************************************************************
       * SAX event handlers
       */
      public void startDocument() throws SAXException {
          // Should never receive this in the midst of a parse.
          if (recorder != null)
              recorder.startDocument();
      }
  
      /**
       * endDocument is invoked at the end of the document.
       */
      public void endDocument() throws SAXException {
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("endDoc00"));
          }
          if (recorder != null)
              recorder.endDocument();
          
          doneParsing = true;
      }
      /**
       * Return if done parsing document.
       */
      public boolean isDoneParsing() {return doneParsing;}
      
      /** Record the current set of prefix mappings in the nsMappings table.
       *
       * !!! We probably want to have this mapping be associated with the
       *     MessageElements, since they may potentially need access to them
       *     long after the end of the prefix mapping here.  (example:
       *     when we need to record a long string of events scanning forward
       *     in the document to find an element with a particular ID.)
       */
      public void startPrefixMapping(String prefix, String uri)
          throws SAXException
      {
          if (recorder != null)
              recorder.startPrefixMapping(prefix, uri);
          
          if (startOfMappingsPos == -1)
              startOfMappingsPos = getCurrentRecordPos();
          
          if (prefix != null) {
              namespaces.add(uri, prefix);
          } else {
              namespaces.add(uri, "");
          }
         
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("startPrefix00", prefix, uri));
          }
          
          SOAPHandler handler = getTopHandler();
          if (handler != null)
              handler.startPrefixMapping(prefix, uri);
      }
      
      public void endPrefixMapping(String prefix)
          throws SAXException
      {
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("endPrefix00", prefix));
          }
          
          if (recorder != null)
              recorder.endPrefixMapping(prefix);
          
          SOAPHandler handler = getTopHandler();
          if (handler != null)
              handler.endPrefixMapping(prefix);
      }
      
      public void setDocumentLocator(Locator locator) 
      {
          if (recorder != null)
              recorder.setDocumentLocator(locator);
          this.locator = locator;
      }
  
      public void characters(char[] p1, int p2, int p3) throws SAXException {
          if (recorder != null)
              recorder.characters(p1, p2, p3);
          if (getTopHandler() != null)
              getTopHandler().characters(p1, p2, p3);
      }
      
      public void ignorableWhitespace(char[] p1, int p2, int p3) throws SAXException {
          if (recorder != null)
              recorder.ignorableWhitespace(p1, p2, p3);
          if (getTopHandler() != null)
              getTopHandler().ignorableWhitespace(p1, p2, p3);
      }
   
      public void processingInstruction(String p1, String p2) throws SAXException {
          // must throw an error since SOAP 1.1 doesn't allow
          // processing instructions anywhere in the message
          throw new SAXException(JavaUtils.getMessage("noInstructions00"));
      }
  
      public void skippedEntity(String p1) throws SAXException {
          if (recorder != null)
              recorder.skippedEntity(p1);
          getTopHandler().skippedEntity(p1);
      }
  
      /** 
       * startElement is called when an element is read.  This is the big work-horse.
       *
       * This is a big workhorse.  Manage the state of the parser, check for
       * basic SOAP compliance (envelope, then optional header, then body, etc).
       * 
       * This guy also handles monitoring the recording depth if we're recording
       * (so we know when to stop).
       */
      public void startElement(String namespace, String localName,
                               String qName, Attributes attributes)
          throws SAXException
      {
          SOAPHandler nextHandler = null;
  
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("startElem00",
                      "['" + namespace + "' " + localName + "]"));
          }
          
          String prefix = "";
          int idx = qName.indexOf(":");
          if (idx > 0)
              prefix = qName.substring(0, idx);
  
          if (!handlerStack.isEmpty()) {
              nextHandler = getTopHandler().onStartChild(namespace,
                                                         localName,
                                                         prefix,
                                                         attributes,
                                                         this);
          }
          
          if (nextHandler == null) {
              nextHandler = new SOAPHandler();
          }
          
          pushElementHandler(nextHandler);
  
          nextHandler.startElement(namespace, localName, qName,
                                   attributes, this);
          
          if (recorder != null) {
              recorder.startElement(namespace, localName, qName,
                                    attributes);
              if (!doneParsing)
                  curElement.setContentsIndex(recorder.getLength());
          }
          
          namespaces.push();
          
          startOfMappingsPos = -1;
      }
  
      /**
       * endElement is called at the end tag of an element
       */
      public void endElement(String namespace, String localName, String qName)
          throws SAXException
      {
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("endElem00",
                      "['" + namespace + "' " + localName + "]"));
          }
          
          if (recorder != null)
              recorder.endElement(namespace, localName, qName);
          
          try {
              SOAPHandler handler = popElementHandler();
              handler.endElement(namespace, localName, this);
              
              if (!handlerStack.isEmpty()) {
                  getTopHandler().onEndChild(namespace, localName, this);
              } else {
                  // We should be done!
                  if (category.isDebugEnabled()) {
                      category.debug(JavaUtils.getMessage("endDoc01"));
                  }
              }
              
          } finally {
              if (curElement != null)
                  curElement = curElement.getParent();
          }
      }
  
      /**
       * This class is used to map ID's to an actual value Object or Message
       */
      private static class LocalIDResolver implements IDResolver
      {
          HashMap idMap = null;
  
          /**
           * Add object associated with id
           */
          public void addReferencedObject(String id, Object referent)
          {
              if (idMap == null)
                  idMap = new HashMap();
              
              idMap.put(id, referent);
          }
          
          /**
           * Get object referenced by href
           */
          public Object getReferencedObject(String href)
          {
              if ((idMap == null) || (href == null))
                  return null;
              return idMap.get(href);
          }
      }
  }
  
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/DeserializerImpl.java
  
  Index: DeserializerImpl.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding;
  
  import org.apache.axis.Constants;
  
  import org.apache.axis.message.EnvelopeHandler;
  import org.apache.axis.message.MessageElement;
  import org.apache.axis.message.SAX2EventRecorder;
  import org.apache.axis.message.SAXOutputter;
  import org.apache.axis.message.SOAPHandler;
  import org.apache.axis.utils.JavaUtils;
  import org.apache.log4j.Category;
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  import org.xml.sax.helpers.DefaultHandler;
  
  import org.apache.axis.encoding.Target;
  import javax.xml.rpc.namespace.QName;
  import javax.xml.rpc.JAXRPCException;
  
  import java.io.StringWriter;
  import java.util.Enumeration;
  import java.util.Vector;
  
  /** The Deserializer base class.
   * 
   * @author Glen Daniels (gdaniels@allaire.com)
   * Re-architected for JAX-RPC Compliance by
   * @author Rich Scheuerle (sche@us.ibm.com)
   */
  
  public class DeserializerImpl extends SOAPHandler implements Deserializer
  {
      static Category category =
              Category.getInstance(DeserializerImpl.class.getName());
  
      protected Object value = null;
  
      // isEnded is set when the endElement is called
      protected boolean isEnded = false;
  
      protected Vector targets = null;
  
      /** 
       * JAX-RPC compliant method which returns mechanism type.
       */
      public String getMechanismType() {
          return Constants.AXIS_SAX;
      }
      
      /** 
       * Get the deserialized value.
       * @return Object representing deserialized value or null
       */
      public Object getValue()
      {
          return value;
      }
      /** 
       * Set the deserialized value.
       * @param Object representing deserialized value
       */
      public void setValue(Object value)
      {
          this.value = value;
      }
  
      /** 
       * If the deserializer has component values (like ArrayDeserializer)
       * this method gets the specific component via the hint.
       * The default implementation returns null.
       * @return Object representing deserialized value or null
       */
      public Object getValue(Object hint)
      {
          return null;  
      }
  
      /** 
       * If the deserializer has component values (like ArrayDeserializer)
       * this method sets the specific component via the hint.
       * The default implementation does nothing.
       * @param Object representing deserialized value or null
       */
      public void setValue(Object value, Object hint) throws SAXException
      {
      }
  
      /**
       * For deserializers of non-primitives, the value may not be
       * known until later (due to multi-referencing).  In such
       * cases the deserializer registers Target object(s).  When
       * the value is known, the set(value) will be invoked for
       * each Target registered with the Deserializer.  The Target
       * object abstracts the function of setting a target with a
       * value.  See the Target interface for more info.
       * @param Target
       */
      public void registerValueTarget(Target target)
      {
          if (targets == null)
              targets = new Vector();
          
          targets.addElement(target);
      }
      
      /**
       * Get the Value Targets of the Deserializer.
       * @return Vector of Target objects or null
       */
      public Vector getValueTargets() {
          return targets;
      }
      
      /**
       * Add someone else's targets to our own (see DeserializationContext)
       *
       * The DeserializationContext only allows one Deserializer to  
       * wait for a unknown multi-ref'ed value.  So to ensure
       * that all of the targets are updated, this method is invoked
       * to copy the Target objects to the waiting Deserializer.
       * @param other is the Deserializer to copy targets from.
       */
      public void copyValueTargets(Deserializer other)
      {
          if ((other == null) || (other.getValueTargets() == null))
              return;
          
          if (targets == null)
              targets = new Vector();
          
          Enumeration e = other.getValueTargets().elements();
          while (e.hasMoreElements()) {
              targets.addElement(e.nextElement());
          }
      }
      
      /**
       * Some deserializers (ArrayDeserializer) require
       * all of the component values to be known before the
       * value is complete.
       * (For the ArrayDeserializer this is important because
       * the elements are stored in an ArrayList, and all values
       * must be known before the ArrayList is converted into the
       * expected array.
       *
       * This routine is used to indicate when the components are ready.
       * The default (true) is useful for most Deserializers.
       */
      public boolean componentsReady() {
          return true; 
      }
  
      /** 
       * The valueComplete() method is invoked when the
       * end tag of the element is read.  This results
       * in the setting of all registered Targets (see
       * registerValueTarget).
       * Note that the valueComplete() only processes
       * the Targets if componentReady() returns true.
       * So if you override componentReady(), then your
       * specific Deserializer will need to call valueComplete()
       * when your components are ready (See ArrayDeserializer)
       */
      public void valueComplete() throws SAXException
      {
          if (componentsReady()) {            
              if (targets != null) {
                  Enumeration e = targets.elements();
                  while (e.hasMoreElements()) {
                      Target target = (Target)e.nextElement();
                      target.set(value);
                      if (category.isDebugEnabled()) {
                          category.debug(JavaUtils.getMessage("setValueInTarget00",
                                                              "" + value, "" + target));
                      }
                  }
              }
          }
      }
      
      private int startIdx = 0;
      private int endIdx = -1;
      protected boolean isHref = false;
      protected boolean isNil  = false;  // xsd:nil attribute is set to true
      protected String id = null;  // Set to the id of the element
      
      /** 
       * Subclasses may override these
       */
  
      /**
       * This method is invoked when an element start tag is encountered.
       * DeserializerImpl provides default behavior, which involves the following:
       *   - directly handling the deserialization of a nill value
       *   - handling the registration of the id value.
       *   - handling the registration of a fixup if this element is an href.
       *   - calling onStartElement to do the actual deserialization if not nill or href cases.
       * @param namespace is the namespace of the element
       * @param localName is the name of the element
       * @param qName is the prefixed qName of the element
       * @param attributes are the attributes on the element...used to get the type
       * @param context is the DeserializationContext
       *
       * Normally a specific Deserializer (FooDeserializer) should extend DeserializerImpl.
       * Here is the flow that will occur in such cases:
       *   1) DeserializerImpl.startElement(...) will be called and do the id/href/nill stuff.
       *   2) If real deserialization needs to take place DeserializerImpl.onStartElement will be
       *      invoked, which will attempt to install the specific Deserializer (FooDeserializer)
       *   3) The FooDeserializer.startElement(...) will be called to do the Foo specific stuff.
       *      This results in a call to FooDeserializer.onStartElement(...) if startElement was
       *      not overridden.
       *   4) The onChildElement(...) method is called for each child element.  Nothing occurs
       *      if not overridden.  The FooDeserializer.onStartChild(...) method should return 
       *      the deserializer for the child element.
       *   5) When the end tag is reached, the endElement(..) method is invoked.  The default 
       *      behavior is to handle hrefs/ids, call onEndElement and then call the Deserializer
       *      valueComplete method.
       * 
       * So the methods that you potentially want to override are:
       *   onStartElement, onStartChild, componentsReady, setValue(object, hint)
       * You probably should not override startElement or endElement.
       * If you need specific behaviour at the end of the element consider overriding
       * onEndElement.
       *
       * See the pre-existing Deserializers for more information.
       */
      public void startElement(String namespace, String localName,
                               String qName, Attributes attributes,
                               DeserializationContext context)
          throws SAXException
      {
          // If the xsi:nil attribute, set the value to null and return since
          // there is nothing to deserialize.
          String nil = Constants.getValue(attributes, Constants.URI_CURRENT_SCHEMA_XSI, "nil");
          if (nil != null && nil.equals("true")) {
            value = null;
            isNil = true;
            return;
          }
  
          // If this element has an id, then associate the value with the id.
          // (Prior to this association, the MessageElement of the element is
          // associated with the id. Failure to replace the MessageElement at this
          // point will cause an infinite loop during deserialization if the 
          // current element contains child elements that cause an href back to this id.)
          // Also note that that endElement() method is responsible for the final
          // assoication of this id with the completed value.
          id = attributes.getValue("id");
          if (id != null) {
              context.addObjectById(id, value);
              if (category.isDebugEnabled()) {
                  category.debug(JavaUtils.getMessage("deserInitPutValueDebug00", "" + value, id));
              }     
          }
  
          String href = attributes.getValue("href");
          if (href != null) {
              isHref = true;
  
              Object ref = context.getObjectByRef(href);            
              if (category.isDebugEnabled()) {
                  category.debug(JavaUtils.getMessage(
                          "gotForID00",
                          new String[] {"" + ref, href, "" + ref.getClass()}));
              }
              
              if (ref == null) {
                  // Nothing yet... register for later interest.
                  context.registerFixup(href, this);
              }
              
              if (ref instanceof MessageElement) {
                  context.replaceElementHandler(new EnvelopeHandler(this));
  
                  SAX2EventRecorder r = context.getRecorder();
                  context.setRecorder(null);
                  ((MessageElement)ref).publishToHandler((DefaultHandler) context);
                  context.setRecorder(r);
              } else {
                  // If the ref is not a MessageElement, then it must be an
                  // element that has already been deserialized.  Use it directly.
                  value = ref;
                  valueComplete();
              }
              
              // !!! INSERT DEALING WITH ATTACHMENTS STUFF HERE?
          } else {
              isHref = false;
              onStartElement(namespace, localName, qName, attributes,
                             context);
          }
      }
  
      /**
       * This method is invoked after startElement when the element requires
       * deserialization (i.e. the element is not an href and the value is not nil.)
       * DeserializerImpl provides default behavior, which simply
       * involves obtaining a correct Deserializer and plugging its handler.
       * @param namespace is the namespace of the element
       * @param localName is the name of the element
       * @param qName is the prefixed qName of the element
       * @param attributes are the attributes on the element...used to get the type
       * @param context is the DeserializationContext
       */
      public void onStartElement(String namespace, String localName,
                               String qName, Attributes attributes,
                               DeserializationContext context)
          throws SAXException
      {
          // If I'm the base class, try replacing myself with an
          // appropriate deserializer gleaned from type info.
          if (this.getClass().equals(DeserializerImpl.class)) {
              QName type = context.getTypeFromAttributes(namespace,
                                                         localName,
                                                         attributes);
              
              if (category.isDebugEnabled()) {
                  category.debug(JavaUtils.getMessage("gotType00", "Deser", "" + type));
              }
              
              // We know we're deserializing, but we don't have
              // a specific deserializer.  So create one using the
              // attribute type qname.
              if (type != null) {
                  Deserializer dser = context.getDeserializerForType(type);
                  if (dser != null) {
                      dser.copyValueTargets(this);
                      context.replaceElementHandler((org.apache.axis.message.SOAPHandler) dser);
                      // And don't forget to give it the start event...
                      dser.startElement(namespace, localName, qName,
                                        attributes, context);
                  }
              } else {
                  startIdx = context.getCurrentRecordPos();
              }
          }
      }
      
      /**
       * onStartChild is called on each child element.
       * The default behavior supplied by DeserializationImpl is to do nothing.
       * A specific deserializer may perform other tasks.  For example a 
       * BeanDeserializer will construct a deserializer for the indicated 
       * property and return it.
       * @param namespace is the namespace of the child element
       * @param localName is the local name of the child element
       * @param prefix is the prefix used on the name of the child element
       * @param attributes are the attributes of the child element
       * @param context is the deserialization context.
       * @return is a Deserializer to use to deserialize a child (must be
       * a derived class of SOAPHandler) or null if no deserialization should
       * be performed.
       */
      public SOAPHandler onStartChild(String namespace, String localName,
                               String prefix, Attributes attributes,
                               DeserializationContext context)
          throws SAXException
      {
          return null;
      }
      
      
  
      /** 
       * endElement is called when the end element tag is reached.
       * It handles href/id information for multi-ref processing
       * and invokes the valueComplete() method of the deserializer
       * which sets the targets with the deserialized value.
       * @param namespace is the namespace of the child element
       * @param localName is the local name of the child element
       * @param context is the deserialization context
       */
      public final void endElement(String namespace, String localName,
                             DeserializationContext context)
          throws SAXException
      {
  
          isEnded = true;
          if (!isHref) {
              onEndElement(namespace, localName, context);
          }
          
          // Time to call valueComplete to copy the value to 
          // the targets.  First a call is made to componentsReady
          // to ensure that all components are ready.
  
          if (componentsReady())
              valueComplete();
  
          // If this element has an id, then associate the value with the id.
          // Subsequent hrefs to the id will obtain the value directly.
          // This is necessary for proper multi-reference deserialization.
          if (id != null) {
              context.addObjectById(id, value);
              if (category.isDebugEnabled()) {
                  category.debug(JavaUtils.getMessage("deserPutValueDebug00", "" + value, id));
              }     
          }
      }
  
     /**
       * onEndElement is called by endElement.  It is not called
       * if the element has an href.
       * @param namespace is the namespace of the child element
       * @param localName is the local name of the child element
       * @param context is the deserialization context
       */
      public void onEndElement(String namespace, String localName,
                             DeserializationContext context)
          throws SAXException
      {
          // If we only have SAX events, but someone really wanted a
          // value, try sending them the contents of this element
          // as a String...
          // ??? Is this the right thing to do here?
          
          if (this.getClass().equals(DeserializerImpl.class) &&
              targets != null &&
              !targets.isEmpty()) {
              endIdx = context.getCurrentRecordPos();
              
              StringWriter writer = new StringWriter();
              SerializationContextImpl serContext = 
                          new SerializationContextImpl(writer,
                                                   context.getMessageContext());
              serContext.setSendDecl(false);
              
              SAXOutputter so = null;
              so = new SAXOutputter(serContext);
              context.getCurElement().publishContents(so);
              
              value = writer.getBuffer().toString();
          }
      }
      
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/DeserializerTarget.java
  
  Index: DeserializerTarget.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding;
  
  import org.xml.sax.SAXException;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.Target;
  
  // Target is a Deserializer.  The set method invokes one of the setValue methods
  // of the deserializer depending on whether a hint was given.  The DeserializerTarget
  // is used in situations when the Deserializer is expecting multiple values and cannot
  // be considered complete until all values are received.
  // (example is an ArrayDeserializer).
  public class DeserializerTarget implements Target {
      public Deserializer target;
      public Object hint;
      public DeserializerTarget(Deserializer target, Object hint)
      {
          this.target = target;
          this.hint = hint;
      }
      
      public void set(Object value) throws SAXException {
          if (hint != null) {
              target.setValue(value, hint);
          } else {
              target.setValue(value);
          }
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/FieldTarget.java
  
  Index: FieldTarget.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding;
  
  import org.xml.sax.SAXException;
  import java.lang.reflect.Field;
  import java.lang.reflect.InvocationTargetException;
  import java.lang.reflect.Method;
  import java.util.Enumeration;
  import java.util.Vector;
  import org.apache.axis.encoding.Target;
  
  // Target is a field.  The set method places the value in the field.
  public class FieldTarget implements Target {
      private Object targetObject;
      private Field targetField;
      
      public FieldTarget(Object targetObject, Field targetField)
      {
          this.targetObject = targetObject;
          this.targetField = targetField;
      }
      
      public FieldTarget(Object targetObject, String fieldName)
          throws NoSuchFieldException
      {
          Class cls = targetObject.getClass();
          targetField = cls.getField(fieldName);
          this.targetObject = targetObject;
      }
      
      public void set(Object value) throws SAXException {
          try {
              targetField.set(targetObject, value);
          } catch (IllegalAccessException accEx) {
              accEx.printStackTrace();
              throw new SAXException(accEx);
          } catch (IllegalArgumentException argEx) {
              argEx.printStackTrace();
              throw new SAXException(argEx);
          }
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/MethodTarget.java
  
  Index: MethodTarget.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding;
  
  import org.xml.sax.SAXException;
  
  import java.lang.reflect.Method;
  import java.lang.reflect.InvocationTargetException;
  import org.apache.axis.encoding.Target;
  
  // Target is set via a method call.  The set method places the value in the field.
  public class MethodTarget implements Target {
      private Object targetObject;
      private Method targetMethod;
      private static final Class [] objArg = new Class [] { Object.class };
      
      public MethodTarget(Object targetObject, String methodName)
          throws NoSuchMethodException
      {
          this.targetObject = targetObject;
          Class cls = targetObject.getClass();
          targetMethod = cls.getMethod(methodName, objArg);
      }
      
      public void set(Object value) throws SAXException {
          try {
              targetMethod.invoke(targetObject, new Object [] { value });
          } catch (IllegalAccessException accEx) {
              accEx.printStackTrace();
              throw new SAXException(accEx);
          } catch (IllegalArgumentException argEx) {
              argEx.printStackTrace();
              throw new SAXException(argEx);
          } catch (InvocationTargetException targetEx) {
              targetEx.printStackTrace();
              throw new SAXException(targetEx);
          }
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/SerializationContextImpl.java
  
  Index: SerializationContextImpl.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding;
  
  import org.apache.axis.AxisEngine;
  import org.apache.axis.Constants;
  import org.apache.axis.Message;
  import org.apache.axis.MessageContext;
  import org.apache.axis.attachments.Attachments;
  import org.apache.axis.client.Call;
  import org.apache.axis.utils.JavaUtils;
  import org.apache.axis.utils.Mapping;
  import org.apache.axis.utils.NSStack;
  import org.apache.axis.utils.XMLUtils;
  import org.apache.log4j.Category;
  import org.w3c.dom.Attr;
  import org.w3c.dom.Element;
  import org.w3c.dom.NamedNodeMap;
  import org.w3c.dom.Node;
  import org.w3c.dom.NodeList;
  import org.w3c.dom.Text;
  import org.xml.sax.Attributes;
  import org.xml.sax.helpers.AttributesImpl;
  
  import javax.xml.rpc.namespace.QName;
  import javax.xml.rpc.JAXRPCException;
  import java.io.IOException;
  import java.io.Writer;
  import java.util.ArrayList;
  import java.util.Date;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.Iterator;
  import java.util.Stack;
  
  /** Manage a serialization, including keeping track of namespace mappings
   * and element stacks.
   *
   * @author Glen Daniels (gdaniels@macromedia.com)
   * @author Rich Scheuerle <sc...@us.ibm.com>
   */
  public class SerializationContextImpl implements SerializationContext
  {
      static Category category =
              Category.getInstance(SerializationContextImpl.class.getName());
  
      private NSStack nsStack = new NSStack();
      private boolean writingStartTag = false;
      private boolean onlyXML = true;
      private int indent=0;
      private boolean startOfDocument = true;
      private Stack elementStack = new Stack();
      private Writer writer;
      private int lastPrefixIndex = 1;
      private MessageContext msgContext;
      private boolean pretty = false;
  
  
      /**
       * Should I write out objects as multi-refs?
       *
       * !!! For now, this is an all-or-nothing flag.  Either ALL objects will
       * be written in-place as hrefs with the full serialization at the end
       * of the body, or we'll write everything inline (potentially repeating
       * serializations of identical objects).
       */
      private boolean doMultiRefs = false;
  
      /**
       * Should I send an XML declaration?
       */
      private boolean sendXMLDecl = true;
  
      /**
       * Should I send xsi:type attributes?
       */
      private boolean sendXSIType = true;
  
      /**
       * A place to hold objects we cache for multi-ref serialization, and
       * remember the IDs we assigned them.
       */
      private HashMap multiRefValues = null;
      private int multiRefIndex = -1;
  
      /**
       * These three variables are necessary to process multi-level object graphs for multi-ref
       * serialization. 
       * While writing out nested multi-ref objects (via outputMultiRef), we 
       * will fill the secondLevelObjects vector with any new objects encountered.
       * The outputMultiRefsFlag indicates whether we are currently within the
       * outputMultiRef() method (so that serialization() knows to update the 
       * secondLevelObjects vector).
       * The forceSer variable is the trigger to force actual serialization of the indicated object.
       */
      private HashSet secondLevelObjects = null;
      private Object forceSer = null;
      private boolean outputMultiRefsFlag = false;
      
      /** 
       * Construct SerializationContextImpl with associated writer
       * @param writer java.io.Writer
       */
      public SerializationContextImpl(Writer writer)
      {
          this.writer = writer;
      }
      
      
      /** 
       * Construct SerializationContextImpl with associated writer and MessageContext
       * @param writer java.io.Writer
       * @param msgContext is the MessageContext
       */
      public SerializationContextImpl(Writer writer, MessageContext msgContext)
      {
          this.writer = writer;
          this.msgContext = msgContext;
  
          AxisEngine engine = null ;
          if ( msgContext != null ) {
              engine = msgContext.getAxisEngine();
              Boolean shouldSendDecl = (Boolean)engine.getOption(
                                                    AxisEngine.PROP_XML_DECL);
              if (shouldSendDecl != null)
                  sendXMLDecl = shouldSendDecl.booleanValue();
              
              Boolean shouldSendMultiRefs = 
                    (Boolean)msgContext.getProperty(AxisEngine.PROP_DOMULTIREFS);
              
              if (shouldSendMultiRefs == null)
                  shouldSendMultiRefs =
                          (Boolean)engine.getOption(AxisEngine.PROP_DOMULTIREFS);
              
              if (shouldSendMultiRefs != null)
                  doMultiRefs = shouldSendMultiRefs.booleanValue();
  
              // The SEND_TYPE_ATTR and PROP_SEND_XSI options indicate
              // whether the elements should have xsi:type attributes.
              // Only turn this off is the user tells us to
              if ( !msgContext.isPropertyTrue(Call.SEND_TYPE_ATTR, true ))
                  sendXSIType = false ;
              
              Boolean opt = (Boolean)engine.getOption(AxisEngine.PROP_SEND_XSI);
              if ((opt != null) && (opt.equals(Boolean.FALSE))) {
                  sendXSIType = false;
              }
          }
      }
  
      /**
       * Get whether the serialization should be pretty printed.
       * @return true/false
       */
      public boolean getPretty() {
          return pretty;
      }
  
      /**
       * Indicate whether the serialization should be pretty printed.
       * @param pretty true/false
       */
      public void setPretty(boolean pretty) {
          this.pretty = pretty;
      }
      
      /**
       * Set whether we are doing multirefs
       */ 
      public void setDoMultiRefs (boolean shouldDo)
      {
          doMultiRefs = shouldDo;
      }
  
      /**
       * Set whether or not we should write XML declarations.
       * @param sendDecl true/false
       */ 
      public void setSendDecl(boolean sendDecl)
      {
          sendXMLDecl = sendDecl;
      }
  
      /**
       * Get whether or not to write xsi:type attributes.
       * @return true/false
       */ 
      public boolean shouldSendXSIType() {
          return sendXSIType;
      }
  
      /**
       * Get the TypeMapping we're using.
       * @return TypeMapping or null
       */ 
      public TypeMapping getTypeMapping()
      {
          if (msgContext == null)
              return null;
          
          return (TypeMapping) msgContext.getTypeMappingRegistry().getTypeMapping(Constants.URI_CURRENT_SOAP_ENC);
      }
  
      /**
       * Get the TypeMappingRegistry we're using.
       * @return TypeMapping or null
       */ 
      public TypeMappingRegistry getTypeMappingRegistry() {
          if (msgContext == null) 
              return null;
          return (TypeMappingRegistry) msgContext.getTypeMappingRegistry();
      }
  
      /**
       * Get a prefix for a namespace URI.  This method will ALWAYS
       * return a valid prefix - if the given URI is already mapped in this
       * serialization, we return the previous prefix.  If it is not mapped,
       * we will add a new mapping and return a generated prefix of the form
       * "ns<num>".
       * @param uri is the namespace uri
       * @return prefix
       */ 
      public String getPrefixForURI(String uri)
      {
          return getPrefixForURI(uri, null);
      }
      
      /**
       * Get a prefix for the given namespace URI.  If one has already been
       * defined in this serialization, use that.  Otherwise, map the passed
       * default prefix to the URI, and return that.  If a null default prefix
       * is passed, use one of the form "ns<num>"
       */ 
      public String getPrefixForURI(String uri, String defaultPrefix)
      {
          if ((uri == null) || (uri.equals("")))
              return null;
  
          String prefix = nsStack.getPrefix(uri);
  
          if (prefix == null && uri.equals(Constants.URI_CURRENT_SOAP_ENC)) {
              prefix = Constants.NSPREFIX_SOAP_ENC;
              registerPrefixForURI(prefix, uri);
          }
  
          if (prefix == null) {
              if (defaultPrefix == null) {
                  prefix = "ns" + lastPrefixIndex++;
              } else {
                  prefix = defaultPrefix;
              }
              registerPrefixForURI(prefix, uri);
          }
  
          return prefix;
      }
  
      /**
       * Register prefix for the indicated uri
       * @param prefix
       * @param uri is the namespace uri
       */
      public void registerPrefixForURI(String prefix, String uri)
      {
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("register00", prefix, uri));
          }
  
          if ((uri != null) && (prefix != null)) {
              nsStack.add(uri, prefix);
          }
      }
  
      /**
       * Return the current message
       */ 
      public Message getCurrentMessage()
      {
          if (msgContext == null)
              return null;
          return msgContext.getCurrentMessage();
      }
  
      /** 
       * Convert QName to a string of the form <prefix>:<localpart>
       * @param QName
       * @return prefixed qname representation for serialization.
       */
      public String qName2String(QName qName)
      {
          String prefix = getPrefixForURI(qName.getNamespaceURI());
          return (((prefix != null)&&(!prefix.equals(""))) ? prefix + ":" : "") +
                 qName.getLocalPart();
      }
  
      /**
       * Get the QName associated with the specified class.
       * @param Class of an object requiring serialization.
       * @return appropriate QName associated with the class.
       */
      public QName getQNameForClass(Class cls)
      {
          return getTypeMapping().getTypeQName(cls);
      }
  
      /**
       * Indicates whether the object should be interpretted as a primitive
       * for the purposes of multi-ref processing.  A primitive value
       * is serialized directly instead of using id/href pairs.  Thus 
       * primitive serialization/deserialization is slightly faster.
       * @param value to be serialized
       * @param javaType is the "real" java type of value.  Used to distinguish
       * between java primitives and their wrapper classes.
       * @return true/false
       */
      public boolean isPrimitive(Object value, Class javaType)
      {
          if (value == null) return true;
  
          if (javaType.isPrimitive()) return true;
  
          if (String.class.isAssignableFrom(javaType)) return true;
          if (Date.class.isAssignableFrom(javaType)) return true;
          if (Hex.class.isAssignableFrom(javaType)) return true;
          if (Element.class.isAssignableFrom(javaType)) return true;
          if (byte[].class.isAssignableFrom(javaType)) return true;
          
          // Note that arrays are not primitives.
          // Also note that java.lang wrapper classes (i.e. java.lang.Integer) are
          // not primitives.
          return false;
      }
  
      /**
       * Serialize the indicated value as an element named qName.  The attributes object are 
       * additional attributes that will be serialized with the qName.  The value
       * could be serialized directly or could be serialized as an href (with the
       * actual serialize taking place later)
       * @param qName is the QName of the element
       * @param attributes are additional attributes
       * @param value is the object to serialize
       * @param javaType is the "real" type of the value.  For primitives, the value is the
       * associated java.lang class.  So the javaType is needed to know that the value 
       * is really a wrapped primitive.
       */
      public void serialize(QName qName, Attributes attributes, Object value, Class javaType)
          throws IOException
      {
          if (value == null) {
              // If the value is null, the element is
              // passed with xsi:nil="true" to indicate that no object is present.
              //
              // There are three approaches that could be taken...
              // 1) (Currently Implemented) Use xsi:nil="true".
              // 2) Emit an empty element.  (This would be deserialized incorrectly.)
              // 3) Don't emit an element.  (This could also cause deserialization problems.)
              AttributesImpl attrs = new AttributesImpl();
              if (attributes != null)
                  attrs.setAttributes(attributes);
              attrs.addAttribute(Constants.URI_2001_SCHEMA_XSI, "nil", "xsi:nil",
                                 "CDATA", "true");
              startElement(qName, attrs);
              endElement();
          }
  
          Message msg= getCurrentMessage();
          if(null != msg){
              //Get attachments. returns null if no attachment support.
              Attachments attachments= getCurrentMessage().getAttachments();
  
              if( null != attachments && attachments.isAttachment(value)){
               //Attachment support and this is an object that should be treated as an attachment.
  
               //Allow an the attachment to do its own serialization.
                serializeActual(qName, attributes, value, javaType);
                
                //No need to add to mulitRefs. Attachment data stream handled by
                // the message;
                return;
              }
          }
  
          // If multi-reference is enabled and this object value is not a primitive
          // and we are not forcing serialization of the object, then generate
          // an element href (and store the object for subsequent outputMultiRef 
          // processing.
          if (doMultiRefs && (value != forceSer) && !isPrimitive(value, javaType)) {
              if (multiRefIndex == -1)
                  multiRefValues = new HashMap();
  
              String href = (String)multiRefValues.get(value);
              if (href == null) {
                  multiRefIndex++;
                  href = "id" + multiRefIndex;
                  multiRefValues.put(value, href);
  
                  /** Problem - if we're in the middle of writing out
                   * the multi-refs and hit another level of the
                   * object graph, we need to make sure this object
                   * will get written.  For now, add it to a list
                   * which we'll check each time we're done with
                   * outputMultiRefs().
                   */
                  if (outputMultiRefsFlag) {
                      if (secondLevelObjects == null)
                          secondLevelObjects = new HashSet();
                      secondLevelObjects.add(value);
                  }
              }
  
              AttributesImpl attrs = new AttributesImpl();
              if (attributes != null)
                  attrs.setAttributes(attributes);
              attrs.addAttribute("", Constants.ATTR_HREF, "href",
                                 "CDATA", "#" + href);
  
              startElement(qName, attrs);
              endElement();
              return;
          }
  
          // The forceSer variable is set by outputMultiRefs to force
          // serialization of this object via the serialize(...) call
          // below.  However, if the forced object contains a self-reference, we
          // get into an infinite loop..which is why it is set back to null
          // before the actual serialization.
          if (value == forceSer)
              forceSer = null;
  
          // Actually serialize the value.  (i.e. not an href like above)
          serializeActual(qName, attributes, value, javaType);
      }
  
      /**
       * The serialize method uses hrefs to reference all non-primitive
       * values.  These values are stored and serialized by calling
       * outputMultiRefs after the serialize method completes.
       */
      public void outputMultiRefs() throws IOException
      {
          if (!doMultiRefs || (multiRefValues == null))
              return;
          outputMultiRefsFlag = true;
          AttributesImpl attrs = new AttributesImpl();
          attrs.addAttribute("","","","","");
  
          // explicitly state that this attribute is not a root
          String prefix = getPrefixForURI(Constants.URI_CURRENT_SOAP_ENC);
          String root = prefix + ":root";
          attrs.addAttribute(Constants.URI_CURRENT_SOAP_ENC, Constants.ATTR_ROOT, root, 
                             "CDATA", "0");
  
          Iterator i = ((HashMap)multiRefValues.clone()).keySet().iterator();
          while (i.hasNext()) {
              while (i.hasNext()) {
                  Object val = i.next();
                  String id = (String)multiRefValues.get(val);
                  attrs.setAttribute(0, "", Constants.ATTR_ID, "id", "CDATA",
                                     id);
                  forceSer = val;
                  // Now serialize the value.  Note that it is safe to 
                  // set the javaType argument using value.getClass() because 
                  // values that represent primitives will never get to this point
                  // because they cannot be multi-ref'ed
                  serialize(new QName("","multiRef"), attrs, val, val.getClass());
              }
  
              if (secondLevelObjects != null) {
                  i = secondLevelObjects.iterator();
                  secondLevelObjects = null;
              }
          }
          forceSer = null;
          outputMultiRefsFlag = false;
      }
  
      /**
       * Writes (using the Writer) the start tag for element QName along with the
       * indicated attributes and namespace mappings.
       * @param qName is the name of the element
       * @param attributes are the attributes to write
       */
      public void startElement(QName qName, Attributes attributes)
          throws IOException
      {
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("startElem00",
                      "[" + qName.getNamespaceURI() + "]:" + qName.getLocalPart()));
          }
  
          if (startOfDocument && sendXMLDecl) {
              writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
              startOfDocument = false;
          }
  
          if (writingStartTag) {
              writer.write(">");
              if (pretty) writer.write("\n");
              indent++;
          }
  
          if (pretty) for (int i=0; i<indent; i++) writer.write(' ');
          String elementQName = qName2String(qName);
          writer.write("<");
  
          writer.write(elementQName);
  
          if (attributes != null) {
              for (int i = 0; i < attributes.getLength(); i++) {
                  String qname = attributes.getQName(i);
                  writer.write(" ");
  
                  String prefix = "";
                  String uri = attributes.getURI(i);
                  if (uri != null && !uri.equals("")) {
                      if (qname.equals("")) {
                          // If qname isn't set, generate one
                          prefix = getPrefixForURI(uri);
                      } else {
                          // If it is, make sure the prefix looks reasonable.
                          int idx = qname.indexOf(':');
                          if (idx > -1) {
                              prefix = qname.substring(0, idx);
                              prefix = getPrefixForURI(uri,
                                                       prefix);
                          }
                      }
                      if (!prefix.equals("")) {
                          qname = prefix + ":" + attributes.getLocalName(i);
                      } else {
                          qname = attributes.getLocalName(i);
                      }
                  } else {
                      qname = attributes.getLocalName(i);
                      if(qname == null)
                          qname = attributes.getQName(i);
                  }
  
                  writer.write(qname);
                  writer.write("=\"");
                  writer.write(XMLUtils.xmlEncodeString(attributes.getValue(i)));
                  writer.write("\"");
              }
          }
  
          ArrayList currentMappings = nsStack.peek();
          for (int i = 0; i < currentMappings.size(); i++) {
              Mapping map = (Mapping)currentMappings.get(i);
              writer.write(" xmlns");
              if (!map.getPrefix().equals("")) {
                  writer.write(":");
                  writer.write(map.getPrefix());
              }
              writer.write("=\"");
              writer.write(map.getNamespaceURI());
              writer.write("\"");
          }
  
          writingStartTag = true;
  
          elementStack.push(elementQName);
          nsStack.push();
  
          writer.flush();
          onlyXML=true;
      }
  
      /**
       * Writes the end element tag for the open element.
       **/
      public void endElement()
          throws IOException
      {
          String elementQName = (String)elementStack.pop();
  
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("endElem00", "" + elementQName));
          }
  
          nsStack.pop();
          nsStack.peek().clear();
  
          if (writingStartTag) {
              writer.write("/>");
              if (pretty) writer.write("\n");
              writingStartTag = false;
              return;
          }
  
          if (onlyXML) {
              indent--;
              if (pretty) for (int i=0; i<indent; i++) writer.write(' ');
          }
          writer.write("</");
          writer.write(elementQName);
          writer.write('>');
          if (pretty) if (indent>0) writer.write('\n');
          writer.flush();
          onlyXML=true;
      }
  
      /**
       * Convenience operation to write out (to Writer) the characters
       * in p1 starting at index p2 for length p3.
       * @param p1 character array to write
       * @param p2 starting index in array
       * @param p3 length to write
       */
      public void writeChars(char [] p1, int p2, int p3)
          throws IOException
      {
          if (writingStartTag) {
              writer.write(">");
              writingStartTag = false;
          }
          writeSafeString(String.valueOf(p1,p2,p3));
          writer.flush();
          onlyXML=false;
      }
  
      /**
       * Convenience operation to write out (to Writer) the String
       * @param string is the String to write.
       */
      public void writeString(String string)
          throws IOException
      {
          if (writingStartTag) {
              writer.write(">");
              writingStartTag = false;
          }
          writer.write(string);
          writer.flush();
          onlyXML=false;
      }
  
      /**
       * Convenience operation to write out (to Writer) the String
       * properly encoded with xml entities (like &amp)
       * @param string is the String to write.
       */
      public void writeSafeString(String string)
          throws IOException
      {
          writeString(XMLUtils.xmlEncodeString(string));
      }
  
      /** 
       * Output a DOM representation to a SerializationContext
       * @param el is a DOM Element
       */
      public void writeDOMElement(Element el)
          throws IOException
      {
          AttributesImpl attributes = null;
          NamedNodeMap attrMap = el.getAttributes();
  
          if (attrMap.getLength() > 0) {
              attributes = new AttributesImpl();
              for (int i = 0; i < attrMap.getLength(); i++) {
                  Attr attr = (Attr)attrMap.item(i);
                  String tmp = attr.getNamespaceURI();
                  if ( tmp != null && tmp.equals(Constants.NS_URI_XMLNS) ) {
                      String prefix = attr.getLocalName();
                      if (prefix != null) {
                          if (prefix.equals("xmlns"))
                              prefix = "";
                          String nsURI = attr.getValue();
                          registerPrefixForURI(prefix, nsURI);
                      }
                      continue;
                  }
  
                  attributes.addAttribute(attr.getNamespaceURI(),
                                          attr.getLocalName(),
                                          attr.getName(),
                                          "CDATA", attr.getValue());
              }
          }
  
          String namespaceURI = el.getNamespaceURI();
          String localPart = el.getLocalName();
          if(namespaceURI == null || namespaceURI.length()==0)
              localPart = el.getNodeName();
          QName qName = new QName(namespaceURI, localPart);
  
          startElement(qName, attributes);
  
          NodeList children = el.getChildNodes();
          for (int i = 0; i < children.getLength(); i++) {
              Node child = children.item(i);
              if (child instanceof Element) {
                  writeDOMElement((Element)child);
              } else if (child instanceof Text) {
                  writeSafeString(((Text)child).getData());
              }
          }
  
          endElement();
      }
  
      /**
       * Convenience method to get the Serializer for a specific
       * java type
       * @param javaType is Class for a type to serialize
       * @return Serializer
       */ 
      public final Serializer getSerializerForJavaType(Class javaType) {
          SerializerFactory dserF = null;
          Serializer dser = null;
          try { 
              dserF = (SerializerFactory) getTypeMapping().getSerializer(javaType);
          } catch (JAXRPCException e) {
          }
          if (dserF != null) {
              try {
                  dser = (Serializer) dserF.getSerializerAs(Constants.AXIS_SAX);
              } catch (JAXRPCException e) {}
          }
          return null;
      }
  
      /**
       * Obtains the type attribute that should be serialized and returns the new list of Attributes
       * @param attributes of the qname
       * @param type is the qname of the type
       * @return new list of Attributes
       */
      public Attributes setTypeAttribute(Attributes attributes, QName type)
      {
          if (type == null ||
              !shouldSendXSIType() ||
              ((attributes != null) &&
               (attributes.getIndex(Constants.URI_CURRENT_SCHEMA_XSI,
                                  "type") != -1)))
              return attributes;
          
          AttributesImpl attrs = new AttributesImpl();
          if (attributes != null)
              attrs.setAttributes(attributes);
          
          String prefix = getPrefixForURI(Constants.URI_CURRENT_SCHEMA_XSI,
                                             "xsi");
  
          attrs.addAttribute(Constants.URI_CURRENT_SCHEMA_XSI,
                             "type",
                             prefix + ":type",
                             "CDATA", qName2String(type));
          return attrs;
      }
      
      /**
       * Invoked to do the actual serialization of the qName (called by serialize above).
       * additional attributes that will be serialized with the qName. 
       * @param qName is the QName of the element
       * @param attributes are additional attributes
       * @param value is the object to serialize
       * @param javaType is the "real" type of the value.  For primitives, the value is the
       * associated java.lang class.  So the javaType is needed to know that the value 
       * is really a wrapped primitive.
       */
      public void serializeActual(QName name, Attributes attributes, Object value, Class javaType)
          throws IOException
      {
          if (value != null) {
              TypeMapping tm = getTypeMapping();
              
              if (tm == null) {
                  throw new IOException(JavaUtils.getMessage("noSerializer00",
                                                             value.getClass().getName(), "" + this));
              }
  
              Class_Serializer pair = getSerializer(javaType, value);
              if ( pair != null ) {
                  QName type = tm.getTypeQName(pair.javaType);
                  attributes = setTypeAttribute(attributes, type);
                  pair.ser.serialize(name, attributes, value, this);
                  return;
              }
  
              throw new IOException(JavaUtils.getMessage("noSerializer00",
                      value.getClass().getName(), "" + this));
          }
          // !!! Write out a generic null, or get type info from somewhere else?
      }
  
      class Class_Serializer {
          Serializer ser;
          Class javaType;
      }
      /**
       * getSerializer
       * Attempts to get a serializer for the indicated type. Failure to 
       * find a serializer causes the code to look backwards through the
       * inheritance list.  Continued failured results in an attempt to find
       * a serializer for the type of the value.
       * @param javaType is the type of the object
       * @param value is the object (which may have a different type due to conversions)
       * @return found class/serializer or null
       **/
      private Class_Serializer getSerializer(Class javaType, Object value) {
          Class_Serializer pair = null;
          SerializerFactory  serFactory  = null ;
          TypeMapping tm = getTypeMapping();
          
          // Classes is a list of the inherited interfaces to 
          // check
          ArrayList  classes = null;
          boolean firstPass = true;
          
          // Search for a class that has a serializer factory
          Class _class  = javaType;  
          while( _class != null ) {
              try {
                  serFactory = (SerializerFactory) tm.getSerializer(_class);
              } catch(JAXRPCException e) {
                  // For now continue if JAXRPCException
              }
              if (serFactory  != null) { 
                  break ;
              }
              if ( classes == null ) {
                  classes = new ArrayList();
              }
              Class[] ifaces = _class.getInterfaces();
              for (int i = 0 ; i < ifaces.length ; i++ ) { 
                  classes.add( ifaces[i] );
              }
              _class = _class.getSuperclass();
              
              // Add any non-null (and non-Object) class.  We skip
              // the Object class because if we reach that then
              // there's an error and this error message return 
              // here is better than the one returned by the
              // ObjSerializer.
              if ( _class != null &&
                   !_class.getName().equals("java.lang.Object")) {
                  classes.add( _class );
              }
              
              _class = (!classes.isEmpty()) ? 
                  (Class) classes.remove( 0 ) :
                  null;
  
              // If failed to find a serializerfactory
              // using the javaType, then use the real class of the value
              if (_class == null &&
                  value != null &&
                  value.getClass() != javaType &&
                  firstPass) {
                  firstPass = false;
                  _class = value.getClass();
              }
          }
          
          // Using the serialization factory, create a serializer and
          // serialize the value.
          Serializer ser = null;
          if ( serFactory != null ) {
              try {
                  ser = (Serializer) serFactory.getSerializerAs(Constants.AXIS_SAX);
              } catch (JAXRPCException e) {
              }
          }
          if (ser != null) {
              pair = new Class_Serializer();
              pair.ser = ser;
              pair.javaType = _class;
          }
          return pair; 
      }
  
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/SerializerFactory.java
  
  Index: SerializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  
  package org.apache.axis.encoding;
  
  /**
   * This interface describes the AXIS SerializerFactory.
   *
   * An Axis compliant Serializer Factory must provide one or more 
   * of the following methods:
   *
   * public static create(Class javaType, QName xmlType)
   * public <constructor>(Class javaType, QName xmlType)
   * public <constructor>()
   *
   * The deployment code will attempt to invoke these methods in the above order.
   * The xmlType, javaType arguments are filled in with the values supplied during the
   * deployment registration of the factory.
   */
  public interface SerializerFactory extends javax.xml.rpc.encoding.SerializerFactory {
  }
  
  
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/Target.java
  
  Index: Target.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding;
  
  import org.xml.sax.SAXException;
  
  
  /**
   * A deserializer constructs a value from the xml passed over the wire and
   * sets a target.  The value is set on the target in a number of ways:
   * setting a field, calling a method, setting an indexed property.
   * The Target interface hides the complexity.  The set method is simply
   * invoked with the value.  A class that implements the Target interface
   * needs to supply enough information in the constructor to properly do the
   * set (for example see MethodTarget)
   */
  public interface Target         
  {
      public void set(Object value) throws SAXException;
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/TypeMapping.java
  
  Index: TypeMapping.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  
  package org.apache.axis.encoding;
  
  import javax.xml.rpc.JAXRPCException;
  import javax.xml.rpc.namespace.QName;
  import javax.xml.rpc.encoding.SerializerFactory;
  import javax.xml.rpc.encoding.DeserializerFactory;
  
  
  
  /**
   * This interface describes the AXIS TypeMapping.
   */
  public interface TypeMapping extends javax.xml.rpc.encoding.TypeMapping {
  
      /**
       * Gets the SerializerFactory registered for the specified pair
       * of Java type and XML data type.
       *
       * @param javaType - Class of the Java type
       *
       * @return Registered SerializerFactory
       *
       * @throws JAXRPCException - If there is no registered SerializerFactory 
       * for this pair of Java type and XML data type 
       * java.lang.IllegalArgumentException - If invalid or unsupported XML/Java type is specified
       */
      public SerializerFactory getSerializer(Class javaType)  throws JAXRPCException;
  
      /**
       * Gets the DeserializerFactory registered for the specified pair 
       * of Java type and XML data type.
       *
       * @param javaType - Class of the Java type
       * @param xmlType - Qualified name of the XML data type
       *
       * @return Registered DeserializerFactory
       *
       * @throws JAXRPCException - If there is no registered DeserializerFactory
       * for this pair of Java type and  XML data type 
       * java.lang.IllegalArgumentException - If invalid or unsupported XML/Java type is specified
       */
      public DeserializerFactory getDeserializer(QName xmlType)  throws JAXRPCException;
  
      /**
       * Gets the QName for the type mapped to Class.
       * @param javaType class or type
       * @return xmlType qname or null
       */
      public QName getTypeQName(Class javaType);
  
      /**
       * Gets the Class mapped to QName.
       * @param xmlType qname or null
       * @return javaType class or type
       */
      public Class getClassForQName(QName xmlType);
  }
  
  
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/TypeMappingImpl.java
  
  Index: TypeMappingImpl.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding;
  
  import org.apache.axis.Constants;
  
  import javax.xml.rpc.namespace.QName;
  import javax.xml.rpc.JAXRPCException;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  
  /**
   * @author Rich Scheuerle (scheu@us.ibm.com)
   * 
   * This is the implementation of the axis TypeMapping interface (which extends
   * the JAX-RPC TypeMapping interface).
   * 
   * A TypeMapping is obtained from the singleton TypeMappingRegistry using
   * the namespace of the webservice.  The TypeMapping contains the tuples
   * {Java type, SerializerFactory, DeserializerFactory, Type QName)
   *
   * So if you have a Web Service with the namespace "XYZ", you call 
   * the TypeMappingRegistry.getTypeMapping("XYZ").
   *
   * The wsdl in your web service will use a number of types.  The tuple
   * information for each of these will be accessed via the TypeMapping.
   *
   * Because every web service uses the soap, schema, wsdl primitives, we could 
   * pre-populate the TypeMapping with these standard tuples.  Instead, if requested
   * namespace/class matches is not found in the TypeMapping but matches one these
   * known primitives, the request is delegated to the Default TypeMapping.
   * 
   */
  public class TypeMappingImpl implements TypeMapping { 
  
      public class Pair {
          public Class javaType;
          public QName xmlType;
          public Pair(Class javaType, QName xmlType) {
              this.javaType = javaType;
              this.xmlType = xmlType;
          }
          public boolean equals(Object o) {
              Pair p = (Pair) o;
              return (p.xmlType.equals(this.xmlType) && p.javaType.equals(this.javaType));
          }
          public int hashCode() {
              return javaType.hashCode();
          }
      }
  
      private HashMap qName2Pair;     // QName to Pair Mapping                              
      private HashMap class2Pair;     // Class Name to Pair Mapping                           
      private HashMap pair2SF;        // Pair to Serialization Factory
      private HashMap pair2DF;        // Pair to Deserialization Factory
      private TypeMappingRegistry tmr;  // Back pointer to owning TMR
      protected boolean delegateIfNotFound; // Indicates to delegate to Default if not found
      private ArrayList namespaces;   // Supported namespaces
  
      /**
       * Construct TypeMapping
       */
      public TypeMappingImpl(TypeMappingRegistry tmr) {
          this.tmr = tmr;
          qName2Pair  = new HashMap();
          class2Pair  = new HashMap();
          pair2SF     = new HashMap();
          pair2DF     = new HashMap();
          delegateIfNotFound = true;
          namespaces  = new ArrayList();
      }
      
      /********* JAX-RPC Compliant Method Definitions *****************/
      
      /**
       * Gets the list of encoding styles supported by this TypeMapping object.
       *
       * @return  String[] of namespace URIs for the supported encoding 
       * styles and XML schema namespaces.
       */
      public String[] getSupportedEncodings() {
          return (String[]) namespaces.toArray();
      }
  
      /**
       * Sets the list of encoding styles supported by this TypeMapping object.
       * (Not sure why this is useful...this information is automatically updated
       * during registration.
       *
       * @param namespaceURIs String[] of namespace URI's                
       */
      public void setSupportedEncodings(String[] namespaceURIs) {
          namespaces.clear();
          for (int i =0; i< namespaceURIs.length; i++) {
              if (!namespaces.contains(namespaceURIs[i])) {
                  namespaces.add(namespaceURIs[i]);
              }
          }
      }
      
      /**
       * Registers SerializerFactory and DeserializerFactory for a 
       * specific type mapping between an XML type and Java type.
       *
       * @param javaType - Class of the Java type
       * @param xmlType - Qualified name of the XML data type
       * @param sf - SerializerFactory
       * @param dsf - DeserializerFactory
       *
       * @throws JAXRPCException - If any error during the registration
       */
      public void register(Class javaType, QName xmlType, 
                           javax.xml.rpc.encoding.SerializerFactory sf,
                           javax.xml.rpc.encoding.DeserializerFactory dsf) throws JAXRPCException {        
          if (xmlType.getNamespaceURI() == null ||
              xmlType.getNamespaceURI().equals("") ||
              javaType == null ||
              xmlType == null) {
              throw new JAXRPCException();
          }
          // Make sure the factories conform to the Axis interfaces
          if (sf != null &&
              !(sf instanceof SerializerFactory)) {
              throw new JAXRPCException();
          }
          if (dsf != null &&
              !(dsf instanceof DeserializerFactory)) {
              throw new JAXRPCException();
          }
          Pair pair = new Pair(javaType, xmlType);
  
          qName2Pair.put(xmlType, pair);
          class2Pair.put(javaType, pair);   
          pair2SF.put(pair, sf);
          pair2DF.put(pair, dsf);
      }
      
      /**
       * Gets the SerializerFactory registered for the specified pair
       * of Java type and XML data type.
       *
       * @param javaType - Class of the Java type
       * @param xmlType - Qualified name of the XML data type
       *
       * @return Registered SerializerFactory
       *
       * @throws JAXRPCException - If there is no registered SerializerFactory 
       * for this pair of Java type and XML data type 
       * java.lang.IllegalArgumentException - If invalid or unsupported XML/Java type is specified
       */
      public javax.xml.rpc.encoding.SerializerFactory getSerializer(Class javaType, QName xmlType)
          throws JAXRPCException
      {
          SerializerFactory sf = null;
          // Try to get the serializer associated with this pair
          Pair pair = new Pair(javaType, xmlType);
  
          // If the xmlType was not provided, get one
          if (xmlType == null) {
              pair.xmlType = getTypeQName(javaType);
          }
          // Now get the serializer with the pair
          if (pair.xmlType != null) {
              sf = (SerializerFactory) pair2SF.get(pair);
              // If not successful, use the xmlType to get
              // another pair.  For some xmlTypes (like SOAP_ARRAY)
              // all of the possible javaTypes are not registered.
              if (sf == null) {
                  pair = (Pair) qName2Pair.get(pair.xmlType);
                  if (pair != null) {
                      sf = (SerializerFactory) pair2SF.get(pair);
                  }
              }
          }
          if (sf == null && delegateIfNotFound) {
              TypeMapping defaultTM = (TypeMapping) tmr.getDefaultTypeMapping();
              if (defaultTM != null) {
                  sf = (SerializerFactory) defaultTM.getSerializer(javaType, xmlType);
              }
          }
          return sf;
      }
      public javax.xml.rpc.encoding.SerializerFactory getSerializer(Class javaType) 
          throws JAXRPCException 
      {
          return getSerializer(javaType, null);
      }
  
      /**
       * Gets the DeserializerFactory registered for the specified pair 
       * of Java type and XML data type.
       *
       * @param javaType - Class of the Java type
       * @param xmlType - Qualified name of the XML data type
       *
       * @return Registered DeserializerFactory
       *
       * @throws JAXRPCException - If there is no registered DeserializerFactory
       * for this pair of Java type and  XML data type 
       * java.lang.IllegalArgumentException - If invalid or unsupported XML/Java type is specified
       */
      public javax.xml.rpc.encoding.DeserializerFactory getDeserializer(Class javaType, QName xmlType)
          throws JAXRPCException {
          DeserializerFactory df = null;
          Pair pair = new Pair(javaType, xmlType);
          if (javaType == null) {
              pair.javaType = getClassForQName(xmlType);
          }
          if (pair.javaType != null) {
              df = (DeserializerFactory) pair2DF.get(pair);
          } 
          if (df == null && delegateIfNotFound) {
              TypeMapping defaultTM = (TypeMapping) tmr.getDefaultTypeMapping();
              if (defaultTM != null) {
                  df = (DeserializerFactory) defaultTM.getDeserializer(javaType, xmlType);
              }
          }
          return df;
      }
      public javax.xml.rpc.encoding.DeserializerFactory getDeserializer(QName xmlType)
          throws JAXRPCException {
          return getDeserializer(null, xmlType);
      }
  
      /**
       * Removes the SerializerFactory registered for the specified 
       * pair of Java type and XML data type.
       *
       * @param javaType - Class of the Java type
       * @param xmlType - Qualified name of the XML data type
       *
       * @throws JAXRPCException - If there is error in removing the registered SerializerFactory 
       * java.lang.IllegalArgumentException - If invalid or unsupported XML/Java type is specified
       */
      public void removeSerializer(Class javaType, QName xmlType)
          throws JAXRPCException {
          Pair pair = new Pair(javaType, xmlType);
          pair2SF.remove(pair);
      }
  
      /**
       * Removes the DeserializerFactory registered for the specified 
       * pair of Java type and XML data type.
       *
       * @param javaType - Class of the Java type
       * @param xmlType - Qualified name of the XML data type
       *
       * @throws JAXRPCException - If there is error in removing the registered DeserializerFactory
       * java.lang.IllegalArgumentException - If invalid or unsupported XML/Java type is specified
       */
      public void removeDeserializer(Class javaType, QName xmlType)
          throws JAXRPCException {
          Pair pair = new Pair(javaType, xmlType);
          pair2DF.remove(pair);
      }
  
  
       /********* End JAX-RPC Compliant Method Definitions *****************/
       
      /**
       * Gets the QName for the type mapped to Class.
       * @param javaType class or type
       * @return xmlType qname or null
       */
      public QName getTypeQName(Class javaType) {
          //System.out.println("getTypeQName javaType =" + javaType);
          QName xmlType = null;
          Pair pair = (Pair) class2Pair.get(javaType);
          if (pair == null && delegateIfNotFound) {
              TypeMapping defaultTM = (TypeMapping) tmr.getDefaultTypeMapping();
              if (defaultTM != null) {
                  xmlType = defaultTM.getTypeQName(javaType);
              }
          } else if (pair != null) {
              xmlType = pair.xmlType;
          }
          
          //System.out.println("getTypeQName xmlType =" + xmlType);
          return xmlType;
      }
      
      /**
       * Gets the Class mapped to QName.
       * @param xmlType qname or null
       * @return javaType class or type
       */
      public Class getClassForQName(QName xmlType) {
          //System.out.println("getClassForQName xmlType =" + xmlType);
          Class javaType = null;
          Pair pair = (Pair) qName2Pair.get(xmlType);
          if (pair == null && delegateIfNotFound) {
              TypeMapping defaultTM = (TypeMapping) tmr.getDefaultTypeMapping();
              if (defaultTM != null) {
                  javaType = defaultTM.getClassForQName(xmlType);
              }
          } else if (pair != null) {
              javaType = pair.javaType;
          }
  
          //System.out.println("getClassForQName javaType =" + javaType);
          return javaType;
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/TypeMappingRegistryImpl.java
  
  Index: TypeMappingRegistryImpl.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding;
  
  import org.apache.axis.Constants;
  import org.apache.axis.deployment.wsdd.WSDDConstants;
  import org.apache.axis.utils.JavaUtils;
  
  import javax.xml.rpc.namespace.QName;
  import javax.xml.rpc.JAXRPCException;
  
  import java.beans.IntrospectionException;
  import java.io.IOException;
  import java.io.PrintStream;
  import java.util.HashMap;
  
  /**
   * @author James Snell (jasnell@us.ibm.com)
   * @author Sam Ruby (rubys@us.ibm.com)
   * Re-written for JAX-RPC Compliance by
   * @author Rich Scheuerle (scheu@us.ibm.com
   */
  public class TypeMappingRegistryImpl implements TypeMappingRegistry { 
      
      private HashMap mapTM;          // Type Mappings keyed by the Web Service Namespace URI
      private TypeMapping defaultTM;  // Default Type Mapping 
      
      static private TypeMappingRegistry tmr = new TypeMappingRegistryImpl();
      /**
       * Construct TypeMappingRegistry
       */
      public TypeMappingRegistryImpl() {
          mapTM = new HashMap();
          defaultTM = DefaultTypeMappingImpl.create();
      }
      
      /********* JAX-RPC Compliant Method Definitions *****************/
      
      /**
       * The method register adds a TypeMapping instance for a specific 
       * namespace                 
       *
       * @param mapping - TypeMapping for specific namespaces
       * @param namespaceURIs 
       *
       * @throws JAXRPCException - If there is any error in the registration
       * of the TypeMapping for the specified namespace URI
       * java.lang.IllegalArgumentException - if an invalid namespace URI is specified
       */
      public void register(javax.xml.rpc.encoding.TypeMapping mapping, String[] namespaceURIs)
          throws JAXRPCException {
          if (mapping == null || 
              !(mapping instanceof TypeMapping)) {
              throw new IllegalArgumentException();
          } 
          for (int i = 0; i < namespaceURIs.length; i++) {
              if (namespaceURIs[i] == null) {
                  throw new java.lang.IllegalArgumentException();
              }
              mapTM.put(namespaceURIs[i], mapping);
          }            
      }
      
      /**
       * The method register adds a default TypeMapping instance.  If a specific
       * TypeMapping is not found, the default TypeMapping is used.  
       *
       * @param mapping - TypeMapping for specific type namespaces
       *
       * @throws JAXRPCException - If there is any error in the registration
       * of the TypeMapping for the specified namespace URI
       * java.lang.IllegalArgumentException - if an invalid namespace URI is specified
       */
      public void registerDefault(javax.xml.rpc.encoding.TypeMapping mapping) {
          if (mapping == null || 
              !(mapping instanceof TypeMapping)) {
              throw new IllegalArgumentException();
          }
          defaultTM = (TypeMapping) mapping;
      }
          
      /**
       * Gets the TypeMapping for the namespace.  If not found, the default TypeMapping 
       * is returned.
       *
       * @param namespaceURI - The namespace URI of a Web Service
       * @return The registered TypeMapping (which may be the default TypeMapping) or null.
       */
      public javax.xml.rpc.encoding.TypeMapping getTypeMapping(String namespaceURI) {
          TypeMapping tm = (TypeMapping) mapTM.get(namespaceURI);
          if (tm == null) {
              tm = defaultTM;
          }
          return tm;
      }
  
      /**
       * Removes the TypeMapping for the namespace.
       *
       * @param namespaceURI - The namespace URI
       * @return The registered TypeMapping .
       */
      public javax.xml.rpc.encoding.TypeMapping removeTypeMapping(String namespaceURI) {
          TypeMapping tm = (TypeMapping) mapTM.remove(namespaceURI);
          return tm;
      }
  
  
      /**
       * Creates a new empty TypeMapping object for the specified encoding style or XML schema namespace.
       *
       * @return An empty generic TypeMapping object
       */
      public javax.xml.rpc.encoding.TypeMapping createTypeMapping() {
          return new TypeMappingImpl(this);
      }
          
  
      /**
       * Gets a list of namespace URIs registered with this TypeMappingRegistry.
       *
       * @return String[] containing names of all registered namespace URIs
       */
      public String[] getSupportedNamespaces() {
          return (String[]) mapTM.keySet().toArray();
      }
  
  
      /**
       * Removes all registered TypeMappings from the registery                   
       */
      public void clear(String namespaceURI) {
          mapTM.clear();
      }
  
       /********* End JAX-RPC Compliant Method Definitions *****************/
  
      /**
       * Return the default TypeMapping
       * @return TypeMapping or null
       **/
      public javax.xml.rpc.encoding.TypeMapping getDefaultTypeMapping() {
          return defaultTM;
      }
  
  
      // This code is no longer valid.  If this information should
      // be serialized, the WSDD should do it.  Not the TypeMappingRegistry.
      /* 
      public void dumpToElement(Element root)
      {
          if ((d == null) || (parent == null)) {
              return;
          }
  
          Document doc = root.getOwnerDocument();
          
          Enumeration enum = d.keys();
          while (enum.hasMoreElements()) {
              QName typeQName = (QName)enum.nextElement();
              DeserializerDescriptor desc = 
                                     (DeserializerDescriptor)d.get(typeQName);
              if (desc.cls == null)
                  continue;
              
              Element mapEl = doc.createElementNS("", "typeMapping");
  
              mapEl.setAttribute("type", "ns:" + typeQName.getLocalPart());
              mapEl.setAttribute("xmlns:ns", typeQName.getNamespaceURI());
              
              mapEl.setAttribute("classname", desc.cls.getName());
              
              String dser = desc.factory.getClass().getName();
              mapEl.setAttribute("deserializerFactory", dser);
              
              SerializerDescriptor serDesc =
                                        (SerializerDescriptor)s.get(desc.cls);
              if (serDesc != null) {
                  mapEl.setAttribute("serializer", serDesc.serializer.
                                                        getClass().getName());
              }
  
              root.appendChild(mapEl);
          }
      }
      */
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/ArrayDeserializer.java
  
  Index: ArrayDeserializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  import org.xml.sax.helpers.AttributesImpl;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  import org.apache.axis.message.SOAPHandler;
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerTarget;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  import org.apache.axis.Constants;
  import org.apache.axis.utils.JavaUtils;
  import org.apache.log4j.Category;
  
  import java.lang.reflect.Array;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.Stack;
  import java.util.Vector;
  import java.util.List;
  import java.util.StringTokenizer;
  import java.beans.IntrospectionException;
  
  
  /**
   * An ArrayDeserializer handles deserializing SOAP
   * arrays.
   * 
   * Some code borrowed from ApacheSOAP - thanks to Matt Duftler!
   * 
   * @author Glen Daniels (gdaniels@macromedia.com)
   * 
   * Multi-reference stuff:
   * @author Rich Scheuerle (scheu@us.ibm.com)
   */
  public class ArrayDeserializer extends DeserializerImpl implements Deserializer  {
  
      static Category category =
              Category.getInstance(ArrayDeserializer.class.getName());
  
      public QName arrayType = null;
      public int curIndex = 0;
      QName arrayItemType;
      int length;
      ArrayList mDimLength = null;  // If set, array of multi-dim lengths 
      ArrayList mDimFactor = null;  // If set, array of factors for multi-dim arrays
      HashSet waiting = new HashSet();  // List of indices waiting for completion
  
  
      /**
       * This method is invoked after startElement when the element requires
       * deserialization (i.e. the element is not an href and the value is not nil.)
       * DeserializerImpl provides default behavior, which simply
       * involves obtaining a correct Deserializer and plugging its handler.
       * @param namespace is the namespace of the element
       * @param localName is the name of the element
       * @param qName is the prefixed qname of the element
       * @param attributes are the attributes on the element...used to get the type
       * @param context is the DeserializationContext
       */
      public void onStartElement(String namespace, String localName,
                               String qName, Attributes attributes,
                               DeserializationContext context)
          throws SAXException
      {
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("enter00", "ArrayDeserializer.startElement()"));
          }
  
          QName arrayTypeValue = context.getQNameFromString(
                        Constants.getValue(attributes,
                                           Constants.URI_CURRENT_SOAP_ENC,
                                           Constants.ATTR_ARRAY_TYPE));
          if (arrayTypeValue == null)
              throw new SAXException(JavaUtils.getMessage("noArrayType00"));
          
          String arrayTypeValueNamespaceURI = arrayTypeValue.getNamespaceURI();
          String arrayTypeValueLocalPart = arrayTypeValue.getLocalPart();
          int leftBracketIndex = arrayTypeValueLocalPart.lastIndexOf('[');
          int rightBracketIndex = arrayTypeValueLocalPart.lastIndexOf(']');
  
          if (leftBracketIndex == -1
              || rightBracketIndex == -1
              || rightBracketIndex < leftBracketIndex)
          {
              throw new IllegalArgumentException(
                      JavaUtils.getMessage("badArrayType00", "" + arrayTypeValue));
          }
  
          Class componentType = null;
          String componentTypeName =
                          arrayTypeValueLocalPart.substring(0, leftBracketIndex);
          
          if (componentTypeName.endsWith("]"))
          {
              // If the componentTypeName is an array, use soap_enc:Array
              // with a componentType of ArrayList.class
              arrayItemType = new QName(Constants.URI_CURRENT_SOAP_ENC, "Array");
              componentType = ArrayList.class;
          }
          else
              arrayItemType = new QName(arrayTypeValueNamespaceURI,
                                        componentTypeName);
  
          String lengthStr =
                         arrayTypeValueLocalPart.substring(leftBracketIndex + 1,
                                                           rightBracketIndex);
          
          if (lengthStr.length() > 0)
          {
              try
              {
                  StringTokenizer tokenizer = new StringTokenizer(lengthStr, "[],");
  
                  length = Integer.parseInt(tokenizer.nextToken());
  
                  if (tokenizer.hasMoreTokens())
                      {
                          // If the array is passed as a multi-dimensional array
                          // (i.e. int[2][3]) then store all of the mult-dim lengths.
                          // The valueReady method uses this array to set the
                          // proper mult-dim element.
                          mDimLength = new ArrayList();
                          mDimLength.add(new Integer(length));
                          
                          while(tokenizer.hasMoreTokens()) {
                              mDimLength.add(new Integer(Integer.parseInt(tokenizer.nextToken())));
                          }
                      }
  
  
                  // If the componentType was not already determined to be an 
                  // array, go and get it.
                  if (componentType == null)
                      componentType = context.getTypeMapping().
                                                getClassForQName(arrayItemType);
  
                  if (componentType == null)
                      throw new SAXException(
                              JavaUtils.getMessage("noComponent00",  "" + arrayItemType));
                  
                  
                  // Create an ArrayListExtension class to store the ArrayList
                  // plus converted objects.
                  ArrayList list = new ArrayListExtension(length);
                  // ArrayList lacks a setSize(), so...
                  for (int i = 0; i < length; i++) {
                      list.add(null);
                  }
                  value = list;
  
              }
              catch (NumberFormatException e)
              {
                  throw new IllegalArgumentException(
                          JavaUtils.getMessage("badInteger00", lengthStr));
              }
          }
          else
          {
              // asize with no integers: size must be determined by inspection
              // of the actual members.
              value = new ArrayListExtension();
          }
          
          String offset = Constants.getValue(attributes,
                                           Constants.URI_CURRENT_SOAP_ENC,
                                           Constants.ATTR_OFFSET);
          if (offset != null) {
              leftBracketIndex = offset.lastIndexOf('[');
              rightBracketIndex = offset.lastIndexOf(']');
  
              if (leftBracketIndex == -1
                  || rightBracketIndex == -1
                  || rightBracketIndex < leftBracketIndex)
              {
                  throw new SAXException(
                          JavaUtils.getMessage("badOffset00", offset));
              }
  
              curIndex = convertToIndex(offset.substring(leftBracketIndex + 1,rightBracketIndex),
                                        "badOffset00");
          }
          
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("exit00", "ArrayDeserializer.startElement()"));
          }
      }
      
  
      /**
       * onStartChild is called on each child element.
       * @param namespace is the namespace of the child element
       * @param localName is the local name of the child element
       * @param prefix is the prefix used on the name of the child element
       * @param attributes are the attributes of the child element
       * @param context is the deserialization context.
       * @return is a Deserializer to use to deserialize a child (must be
       * a derived class of SOAPHandler) or null if no deserialization should
       * be performed.
       */
      public SOAPHandler onStartChild(String namespace,
                                      String localName,
                                      String prefix,
                                      Attributes attributes,
                                      DeserializationContext context)
          throws SAXException
      {
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("enter00", "ArrayDeserializer.onStartChild()"));
          }
          
          if (attributes != null) {
              String pos =
                  Constants.getValue(attributes,
                                     Constants.URI_CURRENT_SOAP_ENC,
                                     Constants.ATTR_POSITION);
              if (pos != null) {
                  int leftBracketIndex = pos.lastIndexOf('[');
                  int rightBracketIndex = pos.lastIndexOf(']');
  
                  if (leftBracketIndex == -1
                      || rightBracketIndex == -1
                      || rightBracketIndex < leftBracketIndex)
                  {
                      throw new SAXException(
                              JavaUtils.getMessage("badPosition00", pos));
                  }
                  
                  curIndex = convertToIndex(pos.substring(leftBracketIndex + 1,rightBracketIndex),
                                            "badPosition00");
              }
  
              // If the xsi:nil attribute, set the value to null and return since
              // there is nothing to deserialize.
              if (context.isNil(attributes)) {
                  setValue(null, new Integer(curIndex++));
                  return null;
              }
          }
          
          QName itemType = context.getTypeFromAttributes(namespace,
                                                         localName,
                                                         attributes);
          if (itemType == null)
              itemType = arrayItemType;
          
          Deserializer dSer = context.getDeserializerForType(itemType);
          if (dSer == null) {
              dSer = new DeserializerImpl();  
          }
  
          // Register the callback value target, and
          // keep track of this index so we know when it has been set.
          dSer.registerValueTarget(new DeserializerTarget(this, new Integer(curIndex)));
          waiting.add(new Integer(curIndex));
  
          curIndex++;
          
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("exit00", "ArrayDeserializer.onStartChild()"));
          }
          return (SOAPHandler) dSer;
      }
  
      /** 
       * Need to wait for all indices to be set.
       */
      public boolean componentsReady() {
          return (waiting.size() == 0);
      }
  
      /**
       * set is called during deserialization to assign
       * the Object value to the array position indicated by hint.
       * The hint is always a single Integer.  If the array being
       * deserialized is a multi-dimensional array, the hint is 
       * converted into a series of indices to set the correct
       * nested position.
       * The array deserializer always deserializes into
       * an ArrayList, which is converted and copied into the
       * actual array after completion (by valueComplete).
       * It is important to wait until all indices have been 
       * processed before invoking valueComplete.
       * @param value value of the array element
       * @param hint index of the array element (Integer)
       **/
      public void setValue(Object value, Object hint) throws SAXException
      { 
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("gotValue00", "ArrayDeserializer", "[" + hint +
                                 "] = " + value));
          }
          ArrayList list = (ArrayList)this.value;
          int offset = ((Integer)hint).intValue();
  
          if (this.mDimLength == null) {
              // Normal Case: Set the element in the list
              // grow the list if necessary to accomodate the new member
              while (list.size() <= offset) {
                  list.add(null);
              }
  
              list.set(offset, value);
          } else {
              // Multi-Dim Array case:  Need to find the nested ArrayList
              // and set the proper element.
  
              // Convert the offset into a series of indices
              ArrayList mDimIndex = toMultiIndex(offset);
  
              // Get/Create the nested ArrayList
              for(int i=0; i < mDimLength.size(); i++) {
                  int length = ((Integer)mDimLength.get(i)).intValue();
                  int index  = ((Integer)mDimIndex.get(i)).intValue();
                  while (list.size() < length) {
                      list.add(null);
                  }
                  // If not the last dimension, get the nested ArrayList
                  // Else set the value
                  if (i < mDimLength.size()-1) {
                      if (list.get(index) == null) {
                          list.set(index, new ArrayList());
                      }
                      list = (ArrayList) list.get(index);                    
                  } else {
                      list.set(index, value);
                  }
              }
          }
          // If all indices are accounted for, the array is complete.
          waiting.remove(hint);
          if (isEnded && waiting.size()==0) {
              valueComplete();
          }
      }
      
      /**
       * Converts the given string to an index.
       * Assumes the string consists of a brackets surrounding comma 
       * separated digits.  For example "[2]" or [2,3]".
       * The routine returns a single index.
       * For example "[2]" returns 2.
       * For example "[2,3]" depends on the size of the multiple dimensions.
       *   if the dimensions are "[3,5]" then 13 is returned (2*5) + 3.
       * @param string representing index text
       * @param exceptKey exception message key
       * @return index 
       */
      private int convertToIndex(String text, String exceptKey) throws SAXException {
          StringTokenizer tokenizer = new StringTokenizer(text, "[],");
          int index = 0;
          try {
              if (mDimLength == null) {
                  // Normal Case: Single dimension
                  index = Integer.parseInt(tokenizer.nextToken());
                  if (tokenizer.hasMoreTokens())
                      throw new SAXException(JavaUtils.getMessage(exceptKey, text));
              }
              else {
                  // Multiple Dimensions: 
                  int dim = -1;
                  ArrayList work = new ArrayList();
                  while(tokenizer.hasMoreTokens()) {
                      // Problem if the number of dimensions specified exceeds
                      // the number of dimensions of arrayType
                      dim++;
                      if (dim >= mDimLength.size())
                          throw new SAXException(JavaUtils.getMessage(exceptKey, text));
  
                      // Get the next token and convert to integer
                      int workIndex = Integer.parseInt(tokenizer.nextToken());
  
                      // Problem if the index is out of range.                     
                      if (workIndex < 0 || 
                          workIndex >= ((Integer)mDimLength.get(dim)).intValue())
                          throw new SAXException(JavaUtils.getMessage(exceptKey, text));
                      
                      work.add(new Integer(workIndex));
                  }
                  index = toSingleIndex(work); // Convert to single index
              }
          } catch (SAXException e) {
              throw e;
          } catch (Exception e) {
              throw new SAXException(JavaUtils.getMessage(exceptKey, text));
          }
          return index;
      } 
  
      /**
       * Converts single index to list of multiple indices.
       * @param single index
       * @return list of multiple indices or null if not multiple indices.
       */
      private ArrayList toMultiIndex(int single) {
          if (mDimLength == null) 
              return null;
  
          // Calculate the index factors if not already known
          if (mDimFactor == null) {
              mDimFactor = new ArrayList();
              for (int i=0; i < mDimLength.size(); i++) {
                  int factor = 1;
                  for (int j=i+1; j<mDimLength.size(); j++) {
                      factor *= ((Integer)mDimLength.get(j)).intValue();
                  }
                  mDimFactor.add(new Integer(factor));
              }
          }
  
          ArrayList rc = new ArrayList();
          for (int i=0; i < mDimLength.size(); i++) {
              int factor = ((Integer)mDimFactor.get(i)).intValue();
              rc.add(new Integer(single / factor));
              single = single % factor;
          }
          return rc;
      }
  
      /**
       * Converts multiple index to single index.
       * @param Array list of multiple indices
       * @return single index
       */
      private int toSingleIndex(ArrayList indexArray) {
          if (mDimLength == null || indexArray == null) 
              return -1;
  
          // Calculate the index factors if not already known
          if (mDimFactor == null) {
              mDimFactor = new ArrayList();
              for (int i=0; i < mDimLength.size(); i++) {
                  int factor = 1;
                  for (int j=i+1; j<mDimLength.size(); j++) {
                      factor *= ((Integer)mDimLength.get(j)).intValue();
                  }
                  mDimFactor.add(new Integer(factor));
              }
          }
  
          int single = 0;
          for (int i=0; i < indexArray.size(); i++) {
              single += ((Integer)mDimFactor.get(i)).intValue()*((Integer)indexArray.get(i)).intValue();
          }
          return single;
      }
  
      /**
       * During processing, the Array Deserializer stores the array in 
       * an ArrayListExtension class.  This class contains all of the
       * normal function of an ArrayList, plus it keeps a list of the
       * converted array values.  This class is essential to support
       * arrays that are multi-referenced.
       **/
      public class ArrayListExtension extends ArrayList implements JavaUtils.ConvertCache {
          private HashMap table = null;
          
          /**
           * Constructors
           */
          ArrayListExtension() {
              super();
          }
          ArrayListExtension(int length) {
              super(length);
          }
          /**
           * Store converted value
           **/
          public void setConvertedValue(Class cls, Object value) {
              if (table == null)
                  table = new HashMap();
              table.put(cls, value);
          }
          /**
           * Get previously converted value
           **/
          public Object getConvertedValue(Class cls) {
              if (table == null)
                  return null;
              return table.get(cls);
          }
      }
     
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/ArrayDeserializerFactory.java
  
  Index: ArrayDeserializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  /**
   * DeserializerFactory for arrays
   *
   * @author Rich Scheuerle <sc...@us.ibm.com>
   */
  public class ArrayDeserializerFactory extends BaseDeserializerFactory {
      public ArrayDeserializerFactory() {
          super(ArrayDeserializer.class, false);  // Can't share deserializers     
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/ArraySerializer.java
  
  Index: ArraySerializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  import org.xml.sax.helpers.AttributesImpl;
  
  import org.apache.log4j.Category;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.Constants;
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  
  import org.apache.axis.Constants;
  import org.apache.axis.utils.JavaUtils;
  
  import java.lang.reflect.Array;
  import java.util.ArrayList;
  import java.util.Hashtable;
  import java.util.HashSet;
  import java.util.List;
  import java.util.StringTokenizer;
  
  import java.beans.IntrospectionException;
  
  /**
   * An ArraySerializer handles serializing of arrays.               
   *
   * Some code borrowed from ApacheSOAP - thanks to Matt Duftler!
   * 
   * @author Glen Daniels (gdaniels@macromedia.com)
   * 
   * Multi-reference stuff:
   * @author Rich Scheuerle (scheu@us.ibm.com)
   */
  public class ArraySerializer implements Serializer {
  
      static Category category =
              Category.getInstance(ArraySerializer.class.getName());
      
      /**
       * Serialize an element that is an array.
       * @param name is the element name
       * @param attributes are the attributes...serialize is free to add more.
       * @param value is the value
       * @param context is the SerializationContext
       */
      public void serialize(QName name, Attributes attributes,
                            Object value, SerializationContext context)
          throws IOException
      {
          if (value == null)
              throw new IOException(JavaUtils.getMessage("cantDoNullArray00"));
          
          Class cls = value.getClass();
          List list = null;
          
          if (!cls.isArray()) {
              if (!(value instanceof List)) {
                  throw new IOException(
                          JavaUtils.getMessage("cantSerialize00", cls.getName()));
              }
              list = (List)value;
          }
          
          Class componentType;
          if (list == null) {
              componentType = cls.getComponentType();
          } else {
              if (list.isEmpty()) {
                  componentType = Object.class;
              } else {
                  componentType = list.get(0).getClass();
              }
          }
  
          // Check to see if componentType is also an array.
          // If so, set the componentType to the most nested non-array 
          // componentType.  Increase the dims string by "[]"
          // each time through the loop.  
          // Note from Rich Scheuerle:
          //    This won't handle Lists of Lists or
          //    arrays of Lists....only arrays of arrays.
          String dims = "";
          while (componentType.isArray()) {
              componentType = componentType.getComponentType();
              dims += "[]";
          }
  
         
          QName componentQName = context.getQNameForClass(componentType);
          if (componentQName == null)
              throw new IOException(
                      JavaUtils.getMessage("noType00", componentType.getName()));
          String prefix = context.getPrefixForURI(componentQName.getNamespaceURI());
          String compType = prefix + ":" + componentQName.getLocalPart();
          int len = (list == null) ? Array.getLength(value) : list.size();
  
          String arrayType = compType + dims + "[" + len + "]";
          
          
          // Discover whether array can be serialized directly as a two-dimensional
          // array (i.e. arrayType=int[2,3]) versus an array of arrays.
          // Benefits:
          //   - Less text passed on the wire.
          //   - Easier to read wire format
          //   - Tests the deserialization of multi-dimensional arrays.
          // Drawbacks:
          //   - Is not safe!  It is possible that the arrays are multiply
          //     referenced.  Transforming into a 2-dim array will cause the 
          //     multi-referenced information to be lost.  Plus there is no
          //     way to determine whether the arrays are multi-referenced.
          //     Thus the code is currently disabled (see enable2Dim below).
          //   
          // In the future this code may be enabled for cases that we know
          // are safe.
          // (More complicated processing is necessary for 3-dim arrays, etc.
          // This initial support is mainly used to test deserialization.)
          //
          int dim2Len = -1;
          boolean enable2Dim = false;  // Disabled
          if (enable2Dim && !dims.equals("")) {
              if (cls.isArray() && len > 0) {
                  boolean okay = true;
                  // Make sure all of the component arrays are the same size
                  for (int i=0; i < len && okay; i++) {
                  
                      Object elementValue = Array.get(value, i);
                      if (elementValue == null)
                          okay = false;
                      else if (dim2Len < 0) {
                          dim2Len = Array.getLength(elementValue);
                          if (dim2Len <= 0) {
                              okay = false;
                          }
                      } else if (dim2Len != Array.getLength(elementValue)) {
                          okay = false;
                      }
                  }
                  // Update the arrayType to use mult-dim array encoding
                  if (okay) {
                      dims = dims.substring(0, dims.length()-2);
                      arrayType = compType + dims + "[" + len + "," + dim2Len + "]";
                  } else {
                      dim2Len = -1;
                  }
              }
          }
          
          Attributes attrs = attributes;
          
          if (attributes != null &&
              attributes.getIndex(Constants.URI_CURRENT_SOAP_ENC,
                                  Constants.ATTR_ARRAY_TYPE) == -1) {
              String encprefix = context.getPrefixForURI(Constants.URI_CURRENT_SOAP_ENC);
              AttributesImpl attrImpl = new AttributesImpl(attributes);
              attrImpl.addAttribute(Constants.URI_CURRENT_SOAP_ENC, 
                                    Constants.ATTR_ARRAY_TYPE,
                                    encprefix + ":arrayType",
                                    "CDATA",
                                    arrayType);
              attrs = attrImpl;
          }
          
          context.startElement(name, attrs);
  
          if (dim2Len < 0) {
              // Normal case, serialize each array element
              for (int index = 0; index < len; index++) {
                  Object aValue = (list == null) ? Array.get(value, index) : list.get(index);
                  Class aClass = (aValue == null) ? null : aValue.getClass();
                  
                  context.serialize(new QName("","item"), null, aValue, aClass);
              }
          } else {
              // Serialize as a 2 dimensional array
              for (int index = 0; index < len; index++) {
                  for (int index2 = 0; index2 < dim2Len; index2++) {
                      Object aValue = Array.get(Array.get(value, index), index2);
                      Class aClass = (aValue == null) ? null : aValue.getClass();
                      context.serialize(new QName("","item"), null, aValue, aClass);
                  }
              }
          }
  
          
          context.endElement();
      }
  
      public String getMechanismType() { return Constants.AXIS_SAX; }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/ArraySerializerFactory.java
  
  Index: ArraySerializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  /**
   * SerializerFactory for arrays
   *
   * @author Rich Scheuerle <sc...@us.ibm.com>
   */
  public class ArraySerializerFactory extends BaseSerializerFactory {
      public ArraySerializerFactory() {
          super(ArraySerializer.class, false); 
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/Base64Deserializer.java
  
  Index: Base64Deserializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  import org.apache.axis.encoding.Base64;
  
  /**
   * Deserializer for Base64
   *
   * @author Sam Ruby <ru...@us.ibm.com>
   * Modified by @author Rich scheuerle <sc...@us.ibm.com>
   * @see <a href="http://www.w3.org/TR/xmlschema-2/#base64Binary">XML Schema 3.2.16</a>
   */
  public class Base64Deserializer extends DeserializerImpl implements Deserializer  {
  
      /**
       * Handle any characters found in the data
       */
      public void characters(char [] chars, int start, int end)
          throws SAXException
      {
          value = Base64.decode(chars, start, end);
      }
      
      /**
       * Return something even if no characters were found.
       */
      public void onEndElement(String namespace, String localName,
                               DeserializationContext context)
          throws SAXException
      {
          super.onEndElement(namespace,localName, context);
          if (value == null) value = new byte[0];
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/Base64DeserializerFactory.java
  
  Index: Base64DeserializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  /**
   * DeserializerFactory for hexBinary.
   *
   * @author Rich Scheuerle <sc...@us.ibm.com>
   */
  public class Base64DeserializerFactory extends BaseDeserializerFactory {
      public Base64DeserializerFactory() {
          super(Base64Deserializer.class, false);  // Can't share deserializers     
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/Base64Serializer.java
  
  Index: Base64Serializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.Constants;
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  import org.apache.axis.encoding.Base64;
   
  /**
   * Serializer for Base64
   *
   * @author Sam Ruby <ru...@us.ibm.com>
   * Modified by @author Rich Scheuerle <sc...@us.ibm.com>
   * @see <a href="http://www.w3.org/TR/xmlschema-2/#base64Binary">XML Schema 3.2.16</a>
   */
  public class Base64Serializer implements Serializer {
  
      /** 
       * Serialize a base64 quantity.
       */
      public void serialize(QName name, Attributes attributes,
                            Object value, SerializationContext context)
          throws IOException
      {
          byte[] data = (byte[]) value;
  
          context.startElement(name, attributes);
          context.writeString(Base64.encode(data, 0, data.length));
          context.endElement();
      }
  
      public String getMechanismType() { return Constants.AXIS_SAX; }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/Base64SerializerFactory.java
  
  Index: Base64SerializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  /**
   * SerializerFactory for hexBinary.
   *
   * @author Rich Scheuerle <sc...@us.ibm.com>
   */
  public class Base64SerializerFactory extends BaseSerializerFactory {
      public Base64SerializerFactory() {
          super(Base64Serializer.class, true);  // Share Base64Serializer instance
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/BaseDeserializerFactory.java
  
  Index: BaseDeserializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import javax.xml.rpc.JAXRPCException;
  
  import java.io.IOException;
  import java.util.Vector;
  import java.util.Iterator;
  
  import org.apache.axis.Constants;
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  
  import java.lang.reflect.Constructor;
  import java.lang.reflect.Method;
  
  /**
   * Base class for Axis Deserialization Factory classes for code reuse
   *
   * @author Rich Scheuerle <sc...@us.ibm.com>
   */
  public abstract class BaseDeserializerFactory implements DeserializerFactory {
  
      static Vector mechanisms = null;
      
      protected Class deserClass = null;
      protected boolean share = false;
      protected Deserializer deser = null;
      protected QName xmlType = null;
      protected Class javaType = null;
      protected Constructor dserClassConstructor = null;
  
      /**
       * Constructor
       * @param deserClass is the class of the Deserializer
       * @param share indicates if deserializers can be shared...i.e. getDeserializerAs 
       * will always return the same deserializer object if share is true.  Sharing is
       * only valid for xml primitives.
       */
      public BaseDeserializerFactory(Class deserClass, boolean share) {
          this.deserClass = deserClass;
          this.share = share;
      }
      public BaseDeserializerFactory(Class deserClass, boolean share, QName xmlType, Class javaType) {
          this.deserClass = deserClass;
          this.share = share;
          this.xmlType = xmlType;
          this.javaType = javaType;
      }
  
      public javax.xml.rpc.encoding.Deserializer getDeserializerAs(String mechanismType)
          throws JAXRPCException {
          // Need to add code to check against mechanisms vector.
          if (share && deser != null) {
              return deser;
          }
          // First try to new up the deserializer with qname, class arguments
          deser = null;
          if (javaType != null && xmlType != null) {
              try {
                  if (dserClassConstructor == null) {
                      dserClassConstructor = 
                          deserClass.getConstructor(new Class[] {Class.class, QName.class});
                  }
                  deser = (Deserializer) 
                      dserClassConstructor.newInstance(new Object[] {javaType, xmlType});
              } catch (Exception e) {}
          }
  
          // If not successfull, try newInstance
          if (deser == null) {
              try {
                  deser = (Deserializer) deserClass.newInstance();
              } catch (Exception e) {}
          }
          if (deser == null) {
              throw new JAXRPCException();
          }
          return deser;
      }
  
      /**
       * Returns a list of all XML processing mechanism types supported by this DeserializerFactory.
       *
       * @return List of unique identifiers for the supported XML processing mechanism types
       */
      public Iterator getSupportedMechanismTypes() {
          if (mechanisms == null) {
              mechanisms = new Vector();
              mechanisms.add(Constants.AXIS_SAX);
          }
          return mechanisms.iterator();
      }
  
      /**
       * Utility method that intospects on a factory class to decide how to 
       * create the factory.  Tries in the following order:
       * public static create(Class javaType, QName xmlType)
       * public <constructor>(Class javaType, QName xmlType)
       * public <constructor>()
       * @param factory class
       * @param QName xmlType
       * @param Class javaType
       */
      public static DeserializerFactory createFactory(Class factory, Class javaType, QName xmlType) {
  
          DeserializerFactory df = null;
          try {
              Method method = factory.getMethod("create", new Class[] {Class.class, QName.class});
              df = (DeserializerFactory) method.invoke(null, new Object[] {javaType, xmlType});
          } catch (Exception e) {}
  
          if (df == null) {
              try {
                  Constructor constructor =  
                      factory.getConstructor(new Class[] {Class.class, QName.class});
                  df = (DeserializerFactory) 
                      constructor.newInstance(new Object[] {javaType, xmlType});
              } catch (Exception e) {}
          }
          
          if (df == null) {
              try {
                  df = (DeserializerFactory) factory.newInstance();
              } catch (Exception e) {}
          }
          return df;
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/BaseSerializerFactory.java
  
  Index: BaseSerializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import javax.xml.rpc.JAXRPCException;
  
  import java.io.IOException;
  import java.util.Vector;
  import java.util.Iterator;
  
  import org.apache.axis.Constants;
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  
  import java.lang.reflect.Constructor;
  import java.lang.reflect.Method;
  
  /**
   * Base class for Axis Serialization Factory classes for code reuse
   *
   * @author Rich Scheuerle <sc...@us.ibm.com>
   */
  public abstract class BaseSerializerFactory implements SerializerFactory {
  
      static Vector mechanisms = null;
      
      protected Class serClass = null;
      protected boolean share = false;
      protected Serializer ser = null;
      protected QName xmlType = null;
      protected Class javaType = null;
      protected Constructor serClassConstructor = null;
  
      /**
       * Constructor
       * @param serClass is the class of the Serializer
       * @param share indicates if serializers can be shared...i.e. getSerializerAs 
       * will always return the same serializer object if share is true.  Sharing is
       * only valid for xml primitives.
       */
      public BaseSerializerFactory(Class serClass, boolean share) {
          this.serClass = serClass;
          this.share = share;
      }
      public BaseSerializerFactory(Class serClass, boolean share, QName xmlType, Class javaType) {
          this.serClass = serClass;
          this.share = share;
          this.xmlType = xmlType;
          this.javaType = javaType;
      }
  
      public javax.xml.rpc.encoding.Serializer getSerializerAs(String mechanismType)
          throws JAXRPCException {
          // Need to add code to check against mechanisms vector.
          if (share && ser != null) {
              return ser;
          }
          // First try to new up the serializer with qname, class arguments
          ser = null;
          if (javaType != null && xmlType != null) {
              try {
                  if (serClassConstructor == null) {
                      serClassConstructor = 
                          serClass.getConstructor(new Class[] {Class.class, QName.class});
                  }
                  ser = (Serializer) 
                      serClassConstructor.newInstance(new Object[] {javaType, xmlType});
              } catch (Exception e) {}
          }
          // If not successfull, try newInstance
          if (ser == null) {
              try {
                  ser = (Serializer) serClass.newInstance();
              } catch (Exception e) {
              }
          }
          if (ser == null) {
              throw new JAXRPCException();
          }
          return ser;
      }
  
      /**
       * Returns a list of all XML processing mechanism types supported by this SerializerFactory.
       *
       * @return List of unique identifiers for the supported XML processing mechanism types
       */
      public Iterator getSupportedMechanismTypes() {
          if (mechanisms == null) {
              mechanisms = new Vector();
              mechanisms.add(Constants.AXIS_SAX);
          }
          return mechanisms.iterator();
      }
      
      /**
       * Utility method that intospects on a factory class to decide how to 
       * create the factory.  Tries in the following order:
       * public static create(Class javaType, QName xmlType)
       * public <constructor>(Class javaType, QName xmlType)
       * public <constructor>()
       * @param factory class
       * @param QName xmlType
       * @param Class javaType
       */
      public static SerializerFactory createFactory(Class factory, Class javaType, QName xmlType) {
  
          SerializerFactory sf = null;
          try {
              Method method = factory.getMethod("create", new Class[] {Class.class, QName.class});
              sf = (SerializerFactory) method.invoke(null, new Object[] {javaType, xmlType});
          } catch (Exception e) {}
  
          if (sf == null) {
              try {
                  Constructor constructor =  
                      factory.getConstructor(new Class[] {Class.class, QName.class});
                  sf = (SerializerFactory) 
                      constructor.newInstance(new Object[] {javaType, xmlType});
              } catch (Exception e) {}
          }
          
          if (sf == null) {
              try {
                  sf = (SerializerFactory) factory.newInstance();
              } catch (Exception e) {}
          }
          return sf;
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java
  
  Index: BeanDeserializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  import org.apache.axis.message.SOAPHandler;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  import org.apache.axis.encoding.TypeMapping;
  import org.apache.axis.utils.JavaUtils;
  import java.beans.IntrospectionException;
  
  import java.lang.reflect.Method;
  import java.beans.IntrospectionException;
  import org.apache.log4j.Category;
  import java.beans.Introspector;
  import java.beans.PropertyDescriptor;
  import java.io.ObjectStreamField;
  import java.io.Serializable;
  
  /**
   * General purpose deserializer for an arbitrary java bean.
   *
   * @author Sam Ruby <ru...@us.ibm.com>
   * @author Rich Scheuerle <sc...@us.ibm.com>
   */
  public class BeanDeserializer extends DeserializerImpl implements Deserializer, Serializable  {
      static Category category =
          Category.getInstance(BeanDeserializer.class.getName());
  
      QName xmlType;
      Class javaType;
      private BeanPropertyDescriptor[] pd = null;
  
      // This counter is updated to deal with deserialize collection properties
      protected int collectionIndex = -1;
  
      // Construct BeanSerializer for the indicated class/qname
      public BeanDeserializer(Class javaType, QName xmlType) {
          this.xmlType = xmlType;
          this.javaType = javaType;
          try {
              value=javaType.newInstance();
          } catch (Exception e) {} 
      }
  
      /**
       * Deserializer interface called on each child element encountered in
       * the XML stream.
       * @param namespace is the namespace of the child element
       * @param localName is the local name of the child element
       * @param prefix is the prefix used on the name of the child element
       * @param attributes are the attributes of the child element
       * @param context is the deserialization context.
       * @return is a Deserializer to use to deserialize a child (must be
       * a derived class of SOAPHandler) or null if no deserialization should
       * be performed.
       */
      public SOAPHandler onStartChild(String namespace,
                                      String localName,
                                      String prefix,
                                      Attributes attributes,
                                      DeserializationContext context)
          throws SAXException
      {
          // Get a list of the bean properties
          BeanPropertyDescriptor[] pd = BeanSerializer.getPd(javaType);
  
          // create a value if there isn't one already...
          if (value==null) {
              try {
                  value=javaType.newInstance();
              } catch (Exception e) {
                  throw new SAXException(e.toString());
              }
          }
  
          // look for a field by this name.  Assumes the the number of
          // properties in a bean is (relatively) small, so uses a linear
          // search.  Accept a property if it differs only by the 
          // capitalization of the first character.
          String localNameUp = BeanSerializer.format(localName, BeanSerializer.FORCE_UPPER);
          String localNameLo = BeanSerializer.format(localName, BeanSerializer.FORCE_LOWER);
          for (int i=0; i<pd.length; i++) {
              if (pd[i].getWriteMethod() == null ) continue ;
              if (pd[i].getName().equals(localNameUp) ||
                  pd[i].getName().equals(localNameLo)) {
  
                  // determine the QName for this child element
                  TypeMapping tm = context.getTypeMapping();
                  Class type = pd[i].getType();
                  QName qn = tm.getTypeQName(type);
                  if (qn == null)
                      throw new SAXException(
                              JavaUtils.getMessage("unregistered00", "" + type));
  
                  // get the deserializer
                  Deserializer dSer = context.getDeserializerForType(qn);
                  if (dSer == null)
                      throw new SAXException(
                              JavaUtils.getMessage("noDeser00", "" + type));
  
                  if (pd[i].getWriteMethod().getParameterTypes().length == 1) {
                      // Success!  Register the target and deserializer.
                      collectionIndex = -1;
                      dSer.registerValueTarget(new BeanPropertyTarget(value, pd[i]));
                      return (SOAPHandler) dSer;
                  } else {
                      // Success! This is a collection of properties so use the index
                      collectionIndex++;
                      dSer.registerValueTarget(new BeanPropertyTarget(value, pd[i], collectionIndex));
                      return (SOAPHandler) dSer;
                  }
                      
              }
          }
  
          // No such field
          throw new SAXException(
                  JavaUtils.getMessage("badElem00", javaType.getName(), localName));
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializerFactory.java
  
  Index: BeanDeserializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  import org.apache.axis.utils.JavaUtils;
  
  /**
   * DeserializerFactory for Bean
   *
   * @author Rich Scheuerle <sc...@us.ibm.com>
   */
  public class BeanDeserializerFactory extends BaseDeserializerFactory {
      public BeanDeserializerFactory(Class javaType, QName xmlType) {
          super(BeanDeserializer.class, false, xmlType, javaType);  // Can't share deserializers 
          
          // Sometimes an Enumeration class is registered as a Bean.
          // If this is the case, silently switch to the EnumDeserializer
          if (JavaUtils.isEnumClass(javaType)) {
              deserClass = EnumDeserializer.class;
          }
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/BeanPropertyDescriptor.java
  
  Index: BeanPropertyDescriptor.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.encoding.ser ;
  
  import java.io.ByteArrayOutputStream;
  
  import org.apache.axis.utils.JavaUtils;
  
  import java.lang.reflect.Method;
  import java.beans.IntrospectionException;
  import org.apache.log4j.Category;
  import java.beans.Introspector;
  import java.beans.PropertyDescriptor;
  
  /**
   * This class is essentially a copy of the PropertyDescriptor information, except
   * that the values in it can be modified.
   * @author Rich Scheuerle <sc...@us.ibm.com>
   **/
  class BeanPropertyDescriptor {
      static Category category =
              Category.getInstance(BeanPropertyDescriptor.class.getName());
  
      private String name;
      private Method getter;
      private Method setter;
      
      public BeanPropertyDescriptor(String _name, Method _getter, Method _setter) {
          name = _name;
          getter = _getter;
          setter = _setter;
      }
      public Method getReadMethod()  { return getter; }
      public Method getWriteMethod() { return setter; }
      public String getName() {return name;}
      public Class getType() {return getter.getReturnType(); }
  
      /** 
       * This method attempts to sort the property descriptors to match the 
       * order defined in the class.  This is necessary to support 
       * xsd:sequence processing, which means that the serialized order of 
       * properties must match the xml element order.  (This method assumes that the
       * order of the set methods matches the xml element order...the emitter 
       * will always order the set methods according to the xml order.)
       *
       * This routine also looks for set(i, type) and get(i) methods and adjusts the 
       * property to use these methods instead.  These methods are generated by the
       * emitter for "collection" of properties (i.e. maxOccurs="unbounded" on an element).
       * JAX-RPC is silent on this issue, but web services depend on this kind of behaviour.
       * The method signatures were chosen to match bean indexed properties.
       */
      static BeanPropertyDescriptor[] processPropertyDescriptors(
                    PropertyDescriptor[] rawPd, Class cls) {
          BeanPropertyDescriptor[] myPd = new BeanPropertyDescriptor[rawPd.length];
  
          for (int i=0; i < rawPd.length; i++) {
              myPd[i] = new BeanPropertyDescriptor(rawPd[i].getName(), 
                                                 rawPd[i].getReadMethod(), 
                                                 rawPd[i].getWriteMethod());
          }
          
          try {
              // Create a new pd array and index into the array
              int index = 0;
  
              // Build a new pd array
              // defined by the order of the get methods. 
              BeanPropertyDescriptor[] newPd = new BeanPropertyDescriptor[rawPd.length];
              Method[] methods = cls.getMethods();
              for (int i=0; i < methods.length; i++) {
                  Method method = methods[i];
                  if (method.getName().startsWith("set")) {
                      boolean found = false;
                      for (int j=0; j < myPd.length && !found; j++) {
                          if (myPd[j].getWriteMethod() != null &&
                              myPd[j].getWriteMethod().equals(method)) {
                              found = true;
                              newPd[index] = myPd[j];
                              index++;
                          }
                      }
                  }
              }
              // Now if there are any additional property descriptors, add them to the end.
              if (index < myPd.length) {
                  for (int m=0; m < myPd.length && index < myPd.length; m++) {
                      boolean found = false;           
                      for (int n=0; n < index && !found; n++) {
                          found = (myPd[m]==newPd[n]);
                      }
                      if (!found) {
                          newPd[index] = myPd[m];
                          index++;
                      }
                  }
              }
              // If newPd has same number of elements as myPd, use newPd.
              if (index == myPd.length) {
                  myPd = newPd;
              }
  
              // Get the methods of the class and look for the special set and
              // get methods for property "collections"
              for (int i=0; i < methods.length; i++) {
                  if (methods[i].getName().startsWith("set") && 
                      methods[i].getParameterTypes().length == 2) {
                      for (int j=0; j < methods.length; j++) {
                          if ((methods[j].getName().startsWith("get") ||
                               methods[j].getName().startsWith("is")) &&
                              methods[j].getParameterTypes().length == 1 &&
                              methods[j].getReturnType() == methods[i].getParameterTypes()[1] &&
                              methods[j].getParameterTypes()[0] == int.class &&
                              methods[i].getParameterTypes()[0] == int.class) {
                              for (int k=0; k < myPd.length; k++) {
                                  if (myPd[k].getReadMethod() != null &&
                                      myPd[k].getWriteMethod() != null &&
                                      myPd[k].getReadMethod().getName().equals(methods[j].getName()) &&
                                      myPd[k].getWriteMethod().getName().equals(methods[i].getName())) {
                                      myPd[k] = new BeanPropertyDescriptor(myPd[k].getName(),
                                                                         methods[j],
                                                                         methods[i]);
                                  }
                              }
                          }
                      }
                  }
              }
          } catch (Exception e) {
              // Don't process Property Descriptors if problems occur
              return myPd;
          }
          return myPd;
      }
  }
  
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/BeanPropertyTarget.java
  
  Index: BeanPropertyTarget.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.SAXException;
  import org.apache.log4j.Category;
  
  import java.lang.reflect.Method;
  import org.apache.axis.utils.JavaUtils;
  import org.apache.axis.encoding.Target;
  
  /**
   * Class which knows how to update a bean property
   */
  class BeanPropertyTarget implements Target {
      static Category category =
              Category.getInstance(BeanPropertyTarget.class.getName());
  
      private Object object;
      private BeanPropertyDescriptor pd;
      private int index = -1;
      
      /** 
       * This constructor is used for a normal property.
       * @param Object is the bean class
       * @param pd is the property
       **/
      public BeanPropertyTarget(Object object, BeanPropertyDescriptor pd) {
          this.object = object;
          this.pd     = pd;
          this.index  = -1;  // disable indexing
      }
      
      /** 
       * This constructor is used for an indexed property.
       * @param Object is the bean class
       * @param pd is the property
       * @param i is the index          
       **/
      public BeanPropertyTarget(Object object, BeanPropertyDescriptor pd, int i) {
          this.object = object;
          this.pd     = pd;
          this.index  = i;
      }
      
      public void set(Object value) throws SAXException {
          try {
              if (index < 0)
                  pd.getWriteMethod().invoke(object, new Object[] {value});
              else
                  pd.getWriteMethod().invoke(object, new Object[] {new Integer(index), value});
          } catch (Exception e) {
              Class type = pd.getReadMethod().getReturnType();
              value = JavaUtils.convert(value, type);
              try {
                  if (index < 0)
                      pd.getWriteMethod().invoke(object, new Object[] {value});
                  else
                      pd.getWriteMethod().invoke(object, new Object[] {new Integer(index), value});
              } catch (Exception ex) {
                  String field= pd.getName();
                  int i = 0;
                  if (index >=0) {
                      field += "[" + index + "]";
                      i = 1;
                  }
                  category.error(JavaUtils.getMessage(
                                                      "cantConvert02",
                                                      new String[] {
                                                          value.getClass().getName(),
                                                          field,
                                                          pd.getType().getName()}));
                  throw new SAXException(ex);
              }
          }
      }
  }
  
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializer.java
  
  Index: BeanSerializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.Constants;
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  import org.apache.axis.InternalException;
  
  import java.io.Serializable;
  import java.lang.reflect.Method;
  import java.beans.IntrospectionException;
  import org.apache.log4j.Category;
  import java.beans.Introspector;
  import java.beans.PropertyDescriptor;
  import java.io.ObjectStreamField;
  import java.io.Serializable;
  
  import java.util.HashMap;
  
  /**
   * General purpose serializer/deserializerFactory for an arbitrary java bean.
   *
   * @author Sam Ruby <ru...@us.ibm.com>
   * @author Rich Scheuerle <sc...@us.ibm.com>
   */
  public class BeanSerializer implements Serializer, Serializable {
  
      static Category category =
              Category.getInstance(BeanSerializer.class.getName());
  
      private static final Object[] noArgs = new Object[] {};  // For convenience
  
      // When serializing, the property element names passed over the wire
      // are the names of the properties (format=PROPERTY_NAME).
      // Setting the format to FORCE_UPPER will cause the
      // serializer to uppercase the first letter of the property element name.
      // Setting the format to FORCE_LOWER will cause the
      // serializer to uppercase the first letter of the property element name.
      private short elementPropertyFormat = PROPERTY_NAME;
      public static short PROPERTY_NAME = 0;
      public static short FORCE_UPPER   = 1;
      public static short FORCE_LOWER   = 2;
  
      QName xmlType;
      Class javaType;
  
      // Static Table to store pd[] keyed by class
      private static HashMap pdMap = new HashMap();
  
      // Construct BeanSerializer for the indicated class/qname
      public BeanSerializer(Class javaType, QName xmlType) {
          this.xmlType = xmlType;
          this.javaType = javaType;
      }
  
      // Construct BeanSerializer for the indicated class/qname and format
      public BeanSerializer(Class javaType, QName xmlType, short format) {
          this.xmlType = xmlType;
          this.javaType = javaType;
          if (format > FORCE_LOWER ||
              format < PROPERTY_NAME)
              format = PROPERTY_NAME;
          this.elementPropertyFormat = format;
      }
  
      /**
       * Serialize a bean.  Done simply by serializing each bean property.
       * @param name is the element name
       * @param attributes are the attributes...serialize is free to add more.
       * @param value is the value
       * @param context is the SerializationContext
       */
      public void serialize(QName name, Attributes attributes,
                            Object value, SerializationContext context)
          throws IOException
      {
          // Get the property descriptors describing the bean properties
          BeanPropertyDescriptor[] pd = getPd(javaType);
  
          context.startElement(name, attributes);
  
          try {
              // Serialize each property
              for (int i=0; i<pd.length; i++) {
                  String propName = pd[i].getName();                
                  if (propName.equals("class")) continue;
                  propName = format(propName, elementPropertyFormat);
                  
                  Method readMethod = pd[i].getReadMethod();
                  if (readMethod.getParameterTypes().length == 0) {
                      // Normal case: serialize the value
                      Object propValue = pd[i].getReadMethod().invoke(value,noArgs);
                      context.serialize(new QName("", propName), null, 
                                        propValue,
                                        pd[i].getReadMethod().getReturnType());
                  } else {
                      // Collection of properties: serialize each one
                      int j=0;
                      while(j >= 0) {
                          Object propValue = null;
                          try {
                              propValue = pd[i].getReadMethod().invoke(value,
                                                                       new Object[] { new Integer(j) });
                              j++;
                          } catch (Exception e) {
                              j = -1;
                          }
                          if (j >= 0) {
                              context.serialize(new QName("", propName), null, 
                                                propValue,
                                                pd[i].getReadMethod().getReturnType());
                          }
                      }
                  }
              }
          } catch (Exception e) {
              e.printStackTrace();
              throw new IOException(e.toString());
          }
  
          context.endElement();
      }
  
      /**
       * Get/Create a BeanPropertyDescriptor array for the indicated class.
       */
      static BeanPropertyDescriptor[] getPd(Class javaType) {
          BeanPropertyDescriptor[] pd = (BeanPropertyDescriptor[]) pdMap.get(javaType);
          if (pd == null) {
              try {
                  PropertyDescriptor[] rawPd = Introspector.getBeanInfo(javaType).getPropertyDescriptors();
                  pd = BeanPropertyDescriptor.processPropertyDescriptors(rawPd,javaType);
              } catch (Exception e) {
                  // this should never happen
                  throw new InternalException(e);
              }
          }
          return pd;
      }
  
      /** 
       * Get the format of the elements for the properties
       */
      public short getElementPropertyFormat() {
          return elementPropertyFormat;
      }
      /** 
       * Set the format of the elements for the properties
       */
      public void setElementPropertyFormat(short format) {
          if (format > FORCE_LOWER ||
              format < PROPERTY_NAME)
              format = PROPERTY_NAME;
          elementPropertyFormat = format;
      }
      /**
       * Returns the property name string formatted in the specified manner
       * @param name to format
       * @param fmt (PROPERTY_NAME, FORCE_LOWER, FORCE_UPPER)
       * @return formatted name 
       */
      static String format(String name, short fmt) {
          if (fmt == PROPERTY_NAME)
              return name;
          String theRest = "";
          if (name.length() > 1)
              theRest = name.substring(1);
          if (fmt == FORCE_UPPER)
              return Character.toUpperCase(name.charAt(0)) + theRest;
          else
              return Character.toLowerCase(name.charAt(0)) + theRest;
      }
  
      public String getMechanismType() { return Constants.AXIS_SAX; }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializerFactory.java
  
  Index: BeanSerializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import javax.xml.rpc.JAXRPCException;
  import java.io.IOException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  import org.apache.axis.utils.JavaUtils;
  /**
   * SerializerFactory for Bean
   *
   * @author Rich Scheuerle <sc...@us.ibm.com>
   */
  public class BeanSerializerFactory extends BaseSerializerFactory {
      short format = BeanSerializer.PROPERTY_NAME;
  
      public BeanSerializerFactory(Class javaType, QName xmlType) {
          super(BeanSerializer.class, false, xmlType, javaType);  
          // Sometimes an Enumeration class is registered as a Bean.
          // If this is the case, silently switch to the EnumSerializer
          if (JavaUtils.isEnumClass(javaType)) {
              serClass = EnumSerializer.class;
          }
      }
      // Alternate constructor to set format flag
      public BeanSerializerFactory(Class javaType, QName xmlType, short format) {
          super(BeanSerializer.class, false, xmlType, javaType);  
          // Sometimes an Enumeration class is registered as a Bean.
          // If this is the case, silently switch to the EnumSerializer
          if (JavaUtils.isEnumClass(javaType)) {
              serClass = EnumSerializer.class;
          }
          this.format = format;
      }
  
      public javax.xml.rpc.encoding.Serializer getSerializerAs(String mechanismType)
          throws JAXRPCException {
          Serializer ser = (Serializer) super.getSerializerAs(mechanismType);
          if (ser != null && ser instanceof BeanSerializer) {
              ((BeanSerializer)ser).setElementPropertyFormat(format);
          }
          return ser;
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/DateDeserializer.java
  
  Index: DateDeserializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import java.beans.IntrospectionException;
  import java.io.IOException;
  import java.lang.reflect.Constructor;
  import java.lang.reflect.InvocationTargetException;
  
  import org.apache.axis.InternalException;
  import org.apache.axis.message.SOAPHandler;
  import org.apache.axis.utils.JavaUtils;
  
  import javax.xml.rpc.namespace.QName;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  import java.text.SimpleDateFormat;
  import java.util.Calendar;
  import java.util.Date;
  import java.util.GregorianCalendar;
  import java.util.TimeZone;
  /**
   * The DateSerializer deserializes a Date.  Much of the work is done in the 
   * base class.                                               
   *
   * @author Sam Ruby (rubys@us.ibm.com)
   * Modified for JAX-RPC @author Rich Scheuerle (scheu@us.ibm.com)
   */
  public class DateDeserializer extends SimpleDeserializer {
  
      private static SimpleDateFormat zulu = 
          new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
                            //  0123456789 0 123456789
  
      private static Calendar calendar = new GregorianCalendar();
  
      static {
          zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
      }
  
      /**
       * The Deserializer is constructed with the xmlType and 
       * javaType
       */
      public DateDeserializer(Class javaType, QName xmlType) {
          super(javaType, xmlType);
      }
  
      /**
       * The simple deserializer provides most of the stuff.
       * We just need to override makeValue().
       */
      public Object makeValue(String source) { 
          Date result;
          boolean bc = false;
          
          // validate fixed portion of format
          if ( source != null ) {
              if (source.charAt(0) == '+')
                  source = source.substring(1);
              
              if (source.charAt(0) == '-') {
                  source = source.substring(1);
                  bc = true;
              }
              
              if (source.length() < 19) 
                  throw new NumberFormatException(
                             JavaUtils.getMessage("badDateTime00"));
      
              if (source.charAt(4) != '-' || source.charAt(7) != '-' ||
                  source.charAt(10) != 'T')
                  throw new NumberFormatException(
                                                  JavaUtils.getMessage("badDate00"));
              
              if (source.charAt(13) != ':' || source.charAt(16) != ':')
                  throw new NumberFormatException(
                                                  JavaUtils.getMessage("badTime00"));
          }
          
          // convert what we have validated so far
          try {
              result = zulu.parse(source == null ? null :
                                  (source.substring(0,19)+".000Z") );
          } catch (Exception e) {
              throw new NumberFormatException(e.toString());
          }
          
          int pos = 19;
          
          // parse optional milliseconds
          if ( source != null ) {
              if (pos < source.length() && source.charAt(pos)=='.') {
                  int milliseconds = 0;
                  int start = ++pos;
                  while (pos<source.length() && 
                         Character.isDigit(source.charAt(pos)))
                      pos++;
                  
                  String decimal=source.substring(start,pos);
                  if (decimal.length()==3) {
                      milliseconds=Integer.parseInt(decimal);
                  } else if (decimal.length() < 3) {
                      milliseconds=Integer.parseInt((decimal+"000")
                                                    .substring(0,3));
                  } else {
                      milliseconds=Integer.parseInt(decimal.substring(0,3));
                      if (decimal.charAt(3)>='5') ++milliseconds;
                  }
                  
                  // add milliseconds to the current result
                  result.setTime(result.getTime()+milliseconds);
              }
              
              // parse optional timezone
              if (pos+5 < source.length() &&
                  (source.charAt(pos)=='+' || (source.charAt(pos)=='-')))
                  {
                      if (!Character.isDigit(source.charAt(pos+1)) || 
                          !Character.isDigit(source.charAt(pos+2)) || 
                          source.charAt(pos+3) != ':'              || 
                          !Character.isDigit(source.charAt(pos+4)) || 
                          !Character.isDigit(source.charAt(pos+5)))
                          throw new NumberFormatException(
                                                          JavaUtils.getMessage("badTimezone00"));
                      
                      int hours = (source.charAt(pos+1)-'0')*10
                          +source.charAt(pos+2)-'0';
                      int mins  = (source.charAt(pos+4)-'0')*10
                          +source.charAt(pos+5)-'0';
                      int milliseconds = (hours*60+mins)*60*1000;
                      
                      // subtract milliseconds from current result to obtain GMT
                      if (source.charAt(pos)=='+') milliseconds=-milliseconds;
                      result.setTime(result.getTime()+milliseconds);
                      pos+=6;  
                  }
              
              if (pos < source.length() && source.charAt(pos)=='Z') pos++;
              
              if (pos < source.length())
                  throw new NumberFormatException(
                                                  JavaUtils.getMessage("badChars00"));
          }
          
          // support dates before the Christian era
          if (bc) {
              synchronized (calendar) {
                  calendar.setTime(result);
                  calendar.set(Calendar.ERA, GregorianCalendar.BC);
                  result = calendar.getTime();
              }
          }
          
          return result;
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/DateDeserializerFactory.java
  
  Index: DateDeserializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import java.beans.IntrospectionException;
  import java.io.IOException;
  import java.lang.reflect.Constructor;
  import java.lang.reflect.InvocationTargetException;
  
  import javax.xml.rpc.JAXRPCException;
  import javax.xml.rpc.namespace.QName;
  
  import org.apache.axis.InternalException;
  import org.apache.axis.message.SOAPHandler;
  import org.apache.axis.utils.JavaUtils;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  
  /**
   * A DateDeserializer Factory
   *
   *  @author Rich Scheuerle (scheu@us.ibm.com)
   */
  public class DateDeserializerFactory extends BaseDeserializerFactory {
  
      public DateDeserializerFactory(Class javaType, QName xmlType) {
          super(DateDeserializer.class, false, xmlType, javaType); 
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/DateSerializer.java
  
  Index: DateSerializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.Constants;
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  
  import java.text.SimpleDateFormat;
  import java.util.Calendar;
  import java.util.Date;
  import java.util.GregorianCalendar;
  import java.util.TimeZone;
  
  /**
   * Serializer for Dates.
   *
   * @author Sam Ruby <ru...@us.ibm.com>
   * Modified by @author Rich scheuerle <sc...@us.ibm.com>
   * @see <a href="http://www.w3.org/TR/xmlschema-2/#dateTime">XML Schema 3.2.16</a>
   */
  public class DateSerializer implements Serializer {
  
      private static SimpleDateFormat zulu = 
         new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
                           //  0123456789 0 123456789
  
      private static Calendar calendar = new GregorianCalendar();
  
      static {
          zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
      }
  
      /** 
       * Serialize a Date.
       */
      public void serialize(QName name, Attributes attributes,
                            Object value, SerializationContext context)
          throws IOException
      {
          context.startElement(name, attributes);
          String fdate;
  
          synchronized (calendar) {
              calendar.setTime((Date)value);
              if (calendar.get(Calendar.ERA) == GregorianCalendar.BC) {
                  context.writeString("-");
                  calendar.setTime((Date)value);
                  calendar.set(Calendar.ERA, GregorianCalendar.AD);
                  value = calendar.getTime();
              }
              fdate = zulu.format((Date)value);
          }
  
          context.writeString(fdate);
          context.endElement();
      }
      
      public String getMechanismType() { return Constants.AXIS_SAX; }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/DateSerializerFactory.java
  
  Index: DateSerializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  /**
   * SerializerFactory for Date primitives
   *
   * @author Rich Scheuerle <sc...@us.ibm.com>
   */
  public class DateSerializerFactory extends BaseSerializerFactory {
      public DateSerializerFactory(Class javaType, QName xmlType) {
          super(DateSerializer.class, true, xmlType, javaType);   // true indicates shared class
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/ElementDeserializer.java
  
  Index: ElementDeserializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  import org.w3c.dom.Element;
  
  import java.util.ArrayList;
  
  import org.apache.axis.message.MessageElement ;
  import org.apache.axis.message.SOAPHandler ;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  
  /**
   * Deserializer for DOM elements
   *
   * @author Glen Daniels (gdaniels@macromedia.com)
   * Modified by @author Rich scheuerle <sc...@us.ibm.com>
   */
  public class ElementDeserializer extends DeserializerImpl implements Deserializer  {
  
      public final void onEndElement(String namespace, String localName,
                                     DeserializationContext context)
          throws SAXException
      {
          try {
              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.1                  xml-axis/java/src/org/apache/axis/encoding/ser/ElementDeserializerFactory.java
  
  Index: ElementDeserializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  /**
   * DeserializerFactory for Element.
   *
   * @author Rich Scheuerle <sc...@us.ibm.com>
   */
  public class ElementDeserializerFactory extends BaseDeserializerFactory {
      public ElementDeserializerFactory() {
          super(ElementDeserializer.class, false);  // Can't share deserializers     
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/ElementSerializer.java
  
  Index: ElementSerializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  import org.w3c.dom.Element;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.Constants;
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  import org.apache.axis.utils.JavaUtils;
  
  /**
   * Serializer for DOM elements
   *
   * @author Glen Daniels (gdaniels@macromedia.com)
   * Modified by @author Rich scheuerle <sc...@us.ibm.com>
   */
  
  public class ElementSerializer implements Serializer {
  
      /** 
       * Serialize a DOM Element
       */
      public void serialize(QName name, Attributes attributes,
                            Object value, SerializationContext context)
          throws IOException
      {
          if (!(value instanceof Element))
              throw new IOException(JavaUtils.getMessage("cantSerialize01"));
  
          context.startElement(name, attributes);
          context.writeDOMElement((Element)value);
          context.endElement();
      }
  
      public String getMechanismType() { return Constants.AXIS_SAX; }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/ElementSerializerFactory.java
  
  Index: ElementSerializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  /**
   * SerializerFactory for Element
   *
   * @author Rich Scheuerle <sc...@us.ibm.com>
   */
  public class ElementSerializerFactory extends BaseSerializerFactory {
      public ElementSerializerFactory() {
          super(ElementSerializer.class, true);  // Share ElementSerializer instance
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/EnumDeserializer.java
  
  Index: EnumDeserializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  import java.beans.IntrospectionException;
  import java.lang.reflect.Method;
  
  /**
   * Deserializer for a JAX-RPC enum.
   *
   * @author Rich Scheuerle <sc...@us.ibm.com>
   * @author Sam Ruby <ru...@us.ibm.com>
   */
  public class EnumDeserializer extends SimpleDeserializer implements Deserializer  {
  
      private Method fromStringMethod = null;
  
      public EnumDeserializer(Class javaType, QName xmlType) {
          super(javaType, xmlType);
      }
  
      public Object makeValue(String source) throws Exception
      {
          // Invoke the fromString static method to get the Enumeration value
          if (isNil)
              return null;
          if (fromStringMethod == null) {
              try {
                  fromStringMethod = javaType.getMethod("fromString", 
                                                   new Class[] {java.lang.String.class});
              } catch (Exception e) {
                  throw new IntrospectionException(e.toString());
              }
          }
          return fromStringMethod.invoke(null,new Object [] { source });
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/EnumDeserializerFactory.java
  
  Index: EnumDeserializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  /**
   * DeserializerFactory for Enumeration.
   *
   * @author Rich Scheuerle <sc...@us.ibm.com>
   */
  public class EnumDeserializerFactory extends BaseDeserializerFactory {
      public EnumDeserializerFactory(Class javaType, QName xmlType) {
          super(EnumDeserializer.class, false, xmlType, javaType);  // Can't share deserializers     
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/EnumSerializer.java
  
  Index: EnumSerializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.Constants;
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  import org.apache.axis.InternalException;
  
  import java.io.Serializable;
  import java.lang.reflect.Method;
  import java.beans.IntrospectionException;
  
  
  /**
   * Serializer for a JAX-RPC enum.
   *
   * @author Rich Scheuerle <sc...@us.ibm.com>
   * @author Sam Ruby <ru...@us.ibm.com>
   */
  public class EnumSerializer extends SimpleSerializer implements Serializer {
  
      private java.lang.reflect.Method toStringMethod = null;
      public EnumSerializer(Class javaType, QName xmlType) {
          super(javaType, xmlType);
      }
  
      /** 
       * Serialize an enumeration
       */
      public void serialize(QName name, Attributes attributes,
                            Object value, SerializationContext context)
          throws IOException
      {
          context.startElement(name, attributes);
          
          // Invoke the toString method on the enumeration class and
          // write out the result as a string.
          try {
              if (toStringMethod == null) {
                  toStringMethod = javaType.getMethod("toString", null);
              }
              String propValue = (String) toStringMethod.invoke(value, null);
              context.writeString(propValue);
          } catch (Exception e) {
              e.printStackTrace();
              throw new IOException(e.toString());
          }
          
          context.endElement();
      }
      
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/EnumSerializerFactory.java
  
  Index: EnumSerializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  /**
   * SerializerFactory for Enum
   *
   * @author Rich Scheuerle <sc...@us.ibm.com>
   */
  public class EnumSerializerFactory extends BaseSerializerFactory {
      public EnumSerializerFactory(Class javaType, QName xmlType) {
          super(EnumSerializer.class, true, xmlType, javaType);  // Share EnumSerializer instance
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/HexDeserializer.java
  
  Index: HexDeserializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  import org.apache.axis.encoding.Hex;
  
  /**
   * Deserializer for hexBinary.
   *
   * @author Davanum Srinivas <di...@yahoo.com>
   * Modified by @author Rich scheuerle <sc...@us.ibm.com>
   * @see <a href="http://www.w3.org/TR/xmlschema-2/#hexBinary">XML Schema 3.2.16</a>
   */
  public class HexDeserializer extends DeserializerImpl implements Deserializer  {
      /**
       * Handle any characters found in the data
       */
      public void characters(char [] chars, int start, int end)
          throws SAXException
      {
          value = new Hex(new String(chars, start, end));
      }
      
      /**
       * Return something even if no characters were found.
       */
      public void onEndElement(String namespace, String localName,
                               DeserializationContext context)
          throws SAXException
      {
          super.onEndElement(namespace,localName, context);
          if (value == null) value = new Hex("");
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/HexDeserializerFactory.java
  
  Index: HexDeserializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  /**
   * DeserializerFactory for hexBinary.
   *
   * @author Rich Scheuerle <sc...@us.ibm.com>
   */
  public class HexDeserializerFactory extends BaseDeserializerFactory {
      public HexDeserializerFactory() {
          super(HexDeserializer.class, false);  // Can't share deserializers     
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/HexSerializer.java
  
  Index: HexSerializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.Constants;
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  import org.apache.axis.encoding.Hex;
  /**
   * Serializer for hexBinary.
   *
   * @author Davanum Srinivas <di...@yahoo.com>
   * Modified by @author Rich scheuerle <sc...@us.ibm.com>
   * @see <a href="http://www.w3.org/TR/xmlschema-2/#hexBinary">XML Schema 3.2.16</a>
   */
  public class HexSerializer implements Serializer {
  
      /** 
       * Serialize a Hex quantity.
       */
      public void serialize(QName name, Attributes attributes,
                            Object value, SerializationContext context)
          throws IOException
      {
          Hex data = (Hex) value;
  
          context.startElement(name, attributes);
          context.writeString(data.toString());
          context.endElement();
      }
      
      public String getMechanismType() { return Constants.AXIS_SAX; }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/HexSerializerFactory.java
  
  Index: HexSerializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  /**
   * SerializerFactory for hexBinary.
   *
   * @author Rich Scheuerle <sc...@us.ibm.com>
   */
  public class HexSerializerFactory extends BaseSerializerFactory {
      public HexSerializerFactory() {
          super(HexSerializer.class, true);  // Share HexSerializer instance
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/JAFDataHandlerDeserializer.java
  
  Index: JAFDataHandlerDeserializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import java.util.HashMap;
  import java.util.Map;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  
  import org.apache.axis.utils.JavaUtils;
  import org.apache.axis.Constants;
  import org.apache.axis.message.SOAPHandler;
  import org.apache.axis.attachments.AttachmentUtils;
  import org.apache.log4j.Category;
  
  /**
   * JAFDataHandler Serializer
   * @author Rick Rineholt 
   * Modified by Rich Scheuerle <sc...@us.ibm.com>
   */
  public class JAFDataHandlerDeserializer extends DeserializerImpl implements Deserializer  {
  
      static Category category =
              Category.getInstance(JAFDataHandlerDeserializer.class.getName());
  
      public void startElement(String namespace, String localName,
                               String qName, Attributes attributes,
                               DeserializationContext context)
          throws SAXException{
  
          QName type = context.getTypeFromAttributes(namespace,
                                                     localName,
                                                     attributes);
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("gotType00", "Deser", "" + type));
          }
          
          String href = attributes.getValue("href");
          category.debug("href=" + href);
          if (href != null) {
              Object ref = context.getObjectByRef(href);
              try{
                  ref = AttachmentUtils.getActiviationDataHandler((org.apache.axis.Part)ref); 
              }catch(org.apache.axis.AxisFault e){;}
              
              setValue(ref);
          }
      }
  
      /**
       * Deserializer interface called on each child element encountered in
       * the XML stream.
       */
      public SOAPHandler onStartChild(String namespace,
                                      String localName,
                                      String prefix,
                                      Attributes attributes,
                                      DeserializationContext context)
          throws SAXException {
          throw new SAXException( "The element \"" + namespace + ":" + localName + "\" is an attachment"+
            " with sub elements which is not supported." );
  
  
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/JAFDataHandlerDeserializerFactory.java
  
  Index: JAFDataHandlerDeserializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import java.beans.IntrospectionException;
  import java.io.IOException;
  import java.lang.reflect.Constructor;
  import java.lang.reflect.InvocationTargetException;
  
  import javax.xml.rpc.JAXRPCException;
  import javax.xml.rpc.namespace.QName;
  
  import org.apache.axis.InternalException;
  import org.apache.axis.message.SOAPHandler;
  import org.apache.axis.utils.JavaUtils;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  
  /**
   * A JAFDataHandlerDeserializer Factory
   *
   *  @author Rich Scheuerle (scheu@us.ibm.com)
   */
  public class JAFDataHandlerDeserializerFactory extends BaseDeserializerFactory {
  
      public JAFDataHandlerDeserializerFactory(Class javaType, QName xmlType) {
          super(JAFDataHandlerDeserializer.class, false, xmlType, javaType); 
      }
      public JAFDataHandlerDeserializerFactory() {
          super(JAFDataHandlerDeserializer.class, false); 
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/JAFDataHandlerSerializer.java
  
  Index: JAFDataHandlerSerializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.Constants;
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  import org.apache.axis.utils.JavaUtils;
  
  import javax.activation.DataHandler;
  import org.apache.axis.Part;
  import org.apache.axis.attachments.Attachments;
  import org.apache.axis.Constants;
  import org.xml.sax.Attributes;
  import org.xml.sax.helpers.AttributesImpl;
  
  import java.io.IOException;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  
  import org.apache.log4j.Category;
  
  /**
   * JAFDataHandler Serializer
   * @author Rick Rineholt 
   * Modified by Rich Scheuerle <sc...@us.ibm.com>
   */
  public class JAFDataHandlerSerializer implements Serializer {
  
      static Category category =
              Category.getInstance(JAFDataHandlerSerializer.class.getName());
  
      /** 
       * Serialize a JAF DataHandler quantity.
       */
      public void serialize(QName name, Attributes attributes,
                            Object value, SerializationContext context)
          throws IOException
      {
          DataHandler dh= (DataHandler)value;
          //Add the attachment content to the message.
          Attachments attachments= context.getCurrentMessage().getAttachments();
          Part attachmentPart= attachments.createAttachmentPart(dh);
          String href= attachmentPart.getContentId();
  
          AttributesImpl attrs = new AttributesImpl();
          if (attributes != null)
              attrs.setAttributes(attributes); //copy the existing ones.
  
          int typeIndex=-1;
          if((typeIndex = attrs.getIndex(Constants.URI_CURRENT_SCHEMA_XSI,
                                  "type")) != -1){
  
              //Found a xsi:type which should not be there for attachments.                        
              attrs.removeAttribute(typeIndex);
          }                        
  
          attrs.addAttribute("", Constants.ATTR_HREF, "href",
                                 "CDATA", href);
  
          context.startElement(name, attrs);
          context.endElement(); //There is no data to so end the element.
      }
  
      public String getMechanismType() { return Constants.AXIS_SAX; }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/JAFDataHandlerSerializerFactory.java
  
  Index: JAFDataHandlerSerializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import java.beans.IntrospectionException;
  import java.io.IOException;
  import java.lang.reflect.Constructor;
  import java.lang.reflect.InvocationTargetException;
  
  import javax.xml.rpc.JAXRPCException;
  import javax.xml.rpc.namespace.QName;
  
  import org.apache.axis.InternalException;
  import org.apache.axis.message.SOAPHandler;
  import org.apache.axis.utils.JavaUtils;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  
  /**
   * A JAFDataHandlerSerializer Factory
   *
   *  @author Rich Scheuerle (scheu@us.ibm.com)
   */
  public class JAFDataHandlerSerializerFactory extends BaseSerializerFactory {
  
      public JAFDataHandlerSerializerFactory(Class javaType, QName xmlType) {
          super(JAFDataHandlerSerializer.class, false, xmlType, javaType); 
      }
      public JAFDataHandlerSerializerFactory() {
          super(JAFDataHandlerSerializer.class, false); 
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/MapDeserializer.java
  
  Index: MapDeserializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import java.util.HashMap;
  import java.util.Map;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerTarget;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  
  import org.apache.axis.utils.JavaUtils;
  import org.apache.axis.Constants;
  import org.apache.axis.message.SOAPHandler;
  
  import org.apache.log4j.Category;
  
  /*
   * A <code>MapSerializer</code> is be used to deserialize
   * deserialize Maps using the <code>SOAP-ENC</code>
   * encoding style.<p>
   * 
   * @author Glen Daniels (gdaniels@macromedia.com)
   * Modified by @author Rich scheuerle <sc...@us.ibm.com>
   */
  public class MapDeserializer extends DeserializerImpl implements Deserializer  {
  
      static Category category =
              Category.getInstance(MapDeserializer.class.getName());
  
      // Fixed objects to act as hints to the set() callback
      public static final Object KEYHINT = new Object();
      public static final Object VALHINT = new Object();
      public static final Object NILHINT = new Object();        
  
  
      /**
       * This method is invoked after startElement when the element requires
       * deserialization (i.e. the element is not an href and the value is not nil.)
       * 
       * Simply creates map.
       * @param namespace is the namespace of the element
       * @param localName is the name of the element
       * @param qName is the prefixed qname of the element
       * @param attributes are the attributes on the element...used to get the type
       * @param context is the DeserializationContext
       */
      public void onStartElement(String namespace, String localName,
                                 String qName, Attributes attributes,
                                 DeserializationContext context)
          throws SAXException {
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("enter00", "MapDeserializer.startElement()"));
          }
          
          if (attributes.getValue(Constants.URI_CURRENT_SCHEMA_XSI,  "nil") != null) {
              return;
          }
          
          // Create a hashmap to hold the deserialized values.
          setValue(new HashMap());
          
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("exit00", "MapDeserializer.startElement()"));
          }
      }
      
      /**
       * onStartChild is called on each child element.
       *
       * @param namespace is the namespace of the child element
       * @param localName is the local name of the child element
       * @param prefix is the prefix used on the name of the child element
       * @param attributes are the attributes of the child element
       * @param context is the deserialization context.
       * @return is a Deserializer to use to deserialize a child (must be
       * a derived class of SOAPHandler) or null if no deserialization should
       * be performed.
       */
      public SOAPHandler onStartChild(String namespace,
                                      String localName,
                                      String prefix,
                                      Attributes attributes,
                                      DeserializationContext context)
          throws SAXException {
  
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("enter00", "MapDeserializer.onStartChild()"));
          }
  
          if (!localName.equals("item"))
              throw new SAXException(
                      JavaUtils.getMessage("itemInMap00"));
          
          return new ItemHandler(this);
      }
      
      /**
       * The registerValueTarget code above causes this set function to be invoked when
       * each value is known.
       * @param value is the value of an element
       * @param hint is the key
       */
      public void setValue(Object value, Object hint) throws SAXException
      {
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("gotValue00", "MapDeserializer", "" + value));
          }
          ((Map)this.value).put(hint, value);
      }
      
      /**
       * A deserializer for an <item>.  Handles getting the key and
       * value objects from their own deserializers, and then putting
       * the values into the HashMap we're building.
       * 
       */
      class ItemHandler extends DeserializerImpl implements Deserializer  {
          Object key;
          Object myValue;
          int numSet = 0;
          MapDeserializer md = null;
  
          ItemHandler(MapDeserializer md) {
              this.md = md;
          }
          /** 
           * Callback from our deserializers.  The hint indicates
           * whether the passed "val" argument is the key or the value
           * for this mapping.
           */
          public void setValue(Object val, Object hint) throws SAXException 
          {
              if (hint == KEYHINT) {
                  key = val;
              } else if (hint == VALHINT) {
                  myValue = val;
              } else if (hint != NILHINT) {
                  return;
              }
              numSet++;
              if (numSet == 2)
                  md.setValue(myValue, key);
          }
          
          public SOAPHandler onStartChild(String namespace,
                                      String localName,
                                      String prefix,
                                      Attributes attributes,
                                      DeserializationContext context)
          throws SAXException
          {
              QName typeQName = context.getTypeFromAttributes(namespace,
                                                              localName,
                                                              attributes);
              Deserializer dser = context.getDeserializerForType(typeQName);
  
              // If no deserializer, create DeserializerBase and let it worry
              // about errors
              if (dser == null)
                  dser = new DeserializerImpl();
  
              // When the child value is ready, we
              // want our set method to be invoked.
              // To do this register a DeserializeTarget on the
              // new Deserializer.
              DeserializerTarget dt = null;
              if (context.isNil(attributes)) {
                  dt = new DeserializerTarget(this, NILHINT);
              } else if (localName.equals("key")) {
                  dt = new DeserializerTarget(this, KEYHINT);
              } else if (localName.equals("value")) {
                  dt = new DeserializerTarget(this, VALHINT);
              } else {
                  // Do nothing
              }
              if (dt != null) {
                  dser.registerValueTarget(dt);
              }
              return (SOAPHandler) dser;
          }
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/MapDeserializerFactory.java
  
  Index: MapDeserializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import java.beans.IntrospectionException;
  import java.io.IOException;
  import java.lang.reflect.Constructor;
  import java.lang.reflect.InvocationTargetException;
  
  import javax.xml.rpc.JAXRPCException;
  import javax.xml.rpc.namespace.QName;
  
  import org.apache.axis.InternalException;
  import org.apache.axis.message.SOAPHandler;
  import org.apache.axis.utils.JavaUtils;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  
  /**
   * A MapDeserializer Factory
   *
   *  @author Rich Scheuerle (scheu@us.ibm.com)
   */
  public class MapDeserializerFactory extends BaseDeserializerFactory {
  
      public MapDeserializerFactory(Class javaType, QName xmlType) {
          super(MapDeserializer.class, false, xmlType, javaType); 
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/MapSerializer.java
  
  Index: MapSerializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.Constants;
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  import org.apache.axis.utils.JavaUtils;
  
  import java.io.IOException;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  
  import org.apache.log4j.Category;
  
  /**
   * A <code>MapSerializer</code> is be used to serialize and
   * deserialize Maps using the <code>SOAP-ENC</code>
   * encoding style.<p>
   * 
   * @author Glen Daniels (gdaniels@macromedia.com)
   * Modified by @author Rich Scheuerle (scheu@us.ibm.com)
   */
  
  public class MapSerializer implements Serializer {
  
      static Category category =
              Category.getInstance(MapSerializer.class.getName());
  
      // QNames we deal with
      private static final QName QNAME_KEY = new QName("","key");
      private static final QName QNAME_ITEM = new QName("", "item");
      private static final QName QNAME_VALUE = new QName("", "value");
  
      /** Serialize a Map
       * 
       * Walk the collection of keys, serializing each key/value pair
       * inside an <item> element.
       * 
       * @param name the desired QName for the element
       * @param attributes the desired attributes for the element
       * @param value the Object to serialize
       * @param context the SerializationContext in which to do all this
       * @exception IOException
       */
      public void serialize(QName name, Attributes attributes,
                            Object value, SerializationContext context)
          throws IOException
      {
          if (!(value instanceof Map))
              throw new IOException(
                  JavaUtils.getMessage("noMap00", "MapSerializer", value.getClass().getName()));
          
          Map map = (Map)value;
          
          context.startElement(name, attributes);
  
          for (Iterator i = map.keySet().iterator(); i.hasNext(); )
          {
              Object key = i.next();
              Object val = map.get(key);
  
              context.startElement(QNAME_ITEM, null);
  
              context.serialize(QNAME_KEY,   null, key, (key!=null ? key.getClass(): null) );
              context.serialize(QNAME_VALUE, null, val, (val!=null ? val.getClass(): null));
  
              context.endElement();
          }
  
          context.endElement();
      }
      
      public String getMechanismType() { return Constants.AXIS_SAX; }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/MapSerializerFactory.java
  
  Index: MapSerializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import java.beans.IntrospectionException;
  import java.io.IOException;
  import java.lang.reflect.Constructor;
  import java.lang.reflect.InvocationTargetException;
  
  import javax.xml.rpc.JAXRPCException;
  import javax.xml.rpc.namespace.QName;
  
  import org.apache.axis.InternalException;
  import org.apache.axis.message.SOAPHandler;
  import org.apache.axis.utils.JavaUtils;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  
  /**
   * A MapSerializer Factory
   *
   *  @author Rich Scheuerle (scheu@us.ibm.com)
   */
  public class MapSerializerFactory extends BaseSerializerFactory {
  
      public MapSerializerFactory(Class javaType, QName xmlType) {
          super(MapSerializer.class, false, xmlType, javaType); 
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/SimpleDeserializer.java
  
  Index: SimpleDeserializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import java.beans.IntrospectionException;
  import java.io.IOException;
  import java.lang.reflect.Constructor;
  import java.lang.reflect.InvocationTargetException;
  
  import org.apache.axis.InternalException;
  import org.apache.axis.message.SOAPHandler;
  import org.apache.axis.utils.JavaUtils;
  
  import javax.xml.rpc.namespace.QName;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  
  /**
   * A deserializer for any simple type with a (String) constructor.  Note:
   * this class is designed so that subclasses need only override the makeValue 
   * method in order to construct objects of their own type.
   *
   * @author Glen Daniels (gdaniels@macromedia.com)
   * @author Sam Ruby (rubys@us.ibm.com)
   * Modified for JAX-RPC @author Rich Scheuerle (scheu@us.ibm.com)
   */
  public class SimpleDeserializer extends DeserializerImpl {
  
      StringBuffer val = new StringBuffer();
      private Constructor constructor = null;
  
      public QName xmlType;
      public Class javaType;
  
      /**
       * The Deserializer is constructed with the xmlType and 
       * javaType (which could be a java primitive like int.class)
       */
      public SimpleDeserializer(Class javaType, QName xmlType) {
          this.xmlType = xmlType;
          this.javaType = javaType;
      }
          
      /** 
       * The Factory calls setConstructor.
       */
      public void setConstructor(Constructor c) 
      {
          constructor = c;
      }
  
      /**
       * There should not be nested elements, so thow and exception if this occurs.
       */
      public SOAPHandler onStartChild(String namespace,
                                      String localName,
                                      String prefix,
                                      Attributes attributes,
                                      DeserializationContext context)
          throws SAXException
      {
          throw new SAXException(
                  JavaUtils.getMessage("cantHandle00", "SimpleDeser"));
      }
      
      /**
       * Append any characters received to the value.  This method is defined 
       * by Deserializer.
       */
      public void characters(char [] chars, int start, int end)
          throws SAXException
      {
          val.append(chars, start, end);
      }
      
      /**
       * Append any characters to the value.  This method is defined by 
       * Deserializer.
       */
      public void onEndElement(String namespace, String localName,
                             DeserializationContext context)
          throws SAXException
      {
          try {
              value = makeValue(val.toString());
          } catch (InvocationTargetException ite) {
              Throwable realException = ite.getTargetException();
              if (realException instanceof Exception)
                 throw new SAXException((Exception)realException);
              else
                 throw new SAXException(ite.getMessage());
          } catch (Exception e) {
              throw new SAXException(e);
          }
      }
      
      /**
       * Convert the string that has been accumulated into an Object.  Subclasses
       * may override this.  Note that if the javaType is a primitive, the returned
       * object is a wrapper class.
       * @param string the serialized value to be deserialized
       * @throws Exception any exception thrown by this method will be wrapped
       */
      public Object makeValue(String source) throws Exception
      {
          // If the javaType is a boolean, except a number of different sources
          if (javaType == boolean.class ||
              Boolean.class.isAssignableFrom(javaType)) {
              // This is a pretty lame test, but it is what the previous code did.
              switch (source.charAt(0)) {
                  case '0': case 'f': case 'F':
                     return Boolean.FALSE;
  
                  case '1': case 't': case 'T': 
                     return Boolean.TRUE; 
  
                  default:
                     throw new NumberFormatException(
                             JavaUtils.getMessage("badBool00"));
              }
              
          }
  
          // If expecting a Float or a Double, need to accept some special cases.
          if (javaType == float.class ||
              javaType == java.lang.Float.class) {
              if (source.equals("NaN")) {
                  return new Float(Float.NaN);
              } else if (source.equals("INF")) {
                  return new Float(Float.POSITIVE_INFINITY);
              } else if (source.equals("-INF")) {
                  return new Float(Float.NEGATIVE_INFINITY);
              }
          }
          if (javaType == double.class ||
              javaType == java.lang.Double.class) {
              if (source.equals("NaN")) {
                  return new Double(Double.NaN);
              } else if (source.equals("INF")) {
                  return new Double(Double.POSITIVE_INFINITY);
              } else if (source.equals("-INF")) {
                  return new Double(Double.NEGATIVE_INFINITY);
              }
          }    
          return constructor.newInstance(new Object [] { source });
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/SimpleDeserializerFactory.java
  
  Index: SimpleDeserializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import java.beans.IntrospectionException;
  import java.io.IOException;
  import java.lang.reflect.Constructor;
  import java.lang.reflect.InvocationTargetException;
  
  import javax.xml.rpc.JAXRPCException;
  import javax.xml.rpc.namespace.QName;
  
  import org.apache.axis.InternalException;
  import org.apache.axis.message.SOAPHandler;
  import org.apache.axis.utils.JavaUtils;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  
  /**
   * A deserializer for any simple type with a (String) constructor.  Note:
   * this class is designed so that subclasses need only override the makeValue 
   * method in order to construct objects of their own type.
   *
   * @author Glen Daniels (gdaniels@macromedia.com)
   * @author Sam Ruby (rubys@us.ibm.com)
   * Modified for JAX-RPC @author Rich Scheuerle (scheu@us.ibm.com)
   */
  public class SimpleDeserializerFactory extends BaseDeserializerFactory {
  
      private Constructor constructor = null;
      /**
       * Note that the factory is constructed with the QName and xmlType.  This is important
       * to allow distinction between primitive values and java.lang wrappers.
       **/
      public SimpleDeserializerFactory(Class javaType, QName xmlType) {
          super(SimpleDeserializer.class, false, xmlType, javaType); 
          try {
              if (!javaType.isPrimitive()) {
                  constructor = 
                      javaType.getDeclaredConstructor(new Class [] {String.class});
              }
              else {
                  Class wrapper = null;
                  if (javaType == int.class)
                      wrapper = java.lang.Integer.class;
                  else if (javaType == short.class)
                      wrapper = java.lang.Short.class;
                  else if (javaType == boolean.class)
                      wrapper = java.lang.Boolean.class;
                  else if (javaType == byte.class)
                      wrapper = java.lang.Byte.class;
                  else if (javaType == long.class)
                      wrapper = java.lang.Long.class;
                  else if (javaType == double.class)
                      wrapper = java.lang.Double.class;
                  else if (javaType == float.class)
                      wrapper = java.lang.Float.class;
                  else if (javaType == char.class)
                      wrapper = java.lang.Character.class;
                  if (wrapper != null)
                      constructor = 
                          wrapper.getDeclaredConstructor(new Class [] {String.class});
              }
          } catch (Exception e) {} 
      }
      
      /**
       * Get the Deserializer and the set the Constructor so the
       * deserializer does not have to do introspection.
       */
      public javax.xml.rpc.encoding.Deserializer getDeserializerAs(String mechanismType)
          throws JAXRPCException {
          if (javaType == java.lang.Object.class) {
              return null;
          }
          SimpleDeserializer deser = (SimpleDeserializer) super.getDeserializerAs(mechanismType);
          if (deser != null)
              deser.setConstructor(constructor);
          return deser;
      }
              
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/SimpleNonPrimitiveSerializerFactory.java
  
  Index: SimpleNonPrimitiveSerializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  /**
   * SerializerFactory for simple items that could be multi-refed (i.e. java.lang.Integer)
   *
   * @author Rich Scheuerle <sc...@us.ibm.com>
   */
  public class SimpleNonPrimitiveSerializerFactory extends BaseSerializerFactory {
      /**
       * Note that the factory is constructed with the QName and xmlType.  This is important
       * to allow distinction between primitive values and java.lang wrappers.
       **/
      public SimpleNonPrimitiveSerializerFactory(Class javaType, QName xmlType) {
          super(SimpleSerializer.class, false, xmlType, javaType);  
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/SimplePrimitiveSerializerFactory.java
  
  Index: SimplePrimitiveSerializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  /**
   * SerializerFactory for primitives that have Simple Serialization (i.e. int, short etc.)
   *
   * @author Rich Scheuerle <sc...@us.ibm.com>
   */
  public class SimplePrimitiveSerializerFactory extends BaseSerializerFactory {
      /**
       * Note that the factory is constructed with the QName and xmlType.  This is important
       * to allow distinction between primitive values and java.lang wrappers.
       **/
      public SimplePrimitiveSerializerFactory(Class javaType, QName xmlType) {
          super(SimpleSerializer.class, true, xmlType, javaType);  
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/SimpleSerializer.java
  
  Index: SimpleSerializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import org.apache.axis.Constants;
  import org.apache.axis.utils.JavaUtils;
  import org.apache.axis.utils.XMLUtils;
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  /**
   * Serializer for primitives and anything simple whose value is obtained with toString()
   *
   * @author Rich Scheuerle <di...@yahoo.com>
   */
  public class SimpleSerializer implements Serializer {
  
      public QName xmlType;
      public Class javaType;
      public SimpleSerializer(Class javaType, QName xmlType) {
          this.xmlType = xmlType;
          this.javaType = javaType;
      }
      /** 
       * Serialize a primitive or simple value.
       * If the object to serialize is a primitive, the Object value below
       * is the associated java.lang class.  
       * To determine if the original value is a java.lang class or a primitive, consult
       * the javaType class.
       */
      public void serialize(QName name, Attributes attributes,
                            Object value, SerializationContext context)
          throws IOException
      {
          if (value != null && value.getClass() == java.lang.Object.class) {
              throw new IOException(JavaUtils.getMessage("cantSerialize02"));
          } 
          context.startElement(name, attributes);
          if (value != null) {
              // We could have separate serializers/deserializers to take
              // care of Float/Double cases, but it makes more sence to 
              // put them here with the rest of the java lang primitives.
              if (value instanceof Float ||
                  value instanceof Double) {
                  double data = 0.0;
                  if (value instanceof Float) {
                      data = ((Float) value).doubleValue();
                  } else {
                      data = ((Double) value).doubleValue();
                  }
                  if (data == Double.NaN) {
                      context.writeString("NaN");
                  } else if (data == Double.POSITIVE_INFINITY) {
                      context.writeString("INF");
                  } else if (data == Double.NEGATIVE_INFINITY) {
                      context.writeString("-INF");
                  } else {
                      context.writeString(value.toString());
                  }
              } else if (value instanceof String) {
                  context.writeString(
                                      XMLUtils.xmlEncodeString(value.toString()));
              } else {
                  context.writeString(value.toString());
              }
          }
          context.endElement();
      }
      
      public String getMechanismType() { return Constants.AXIS_SAX; }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/VectorDeserializer.java
  
  Index: VectorDeserializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.IOException;
  
  import java.util.Vector;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerTarget;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  
  import org.apache.axis.utils.JavaUtils;
  import org.apache.axis.Constants;
  import org.apache.axis.message.SOAPHandler;
  
  import org.apache.log4j.Category;
  
  /**
   * Deserializer for SOAP Vectors for compatibility with SOAP 2.2.
   *
   * @author Carsten Ziegeler (cziegeler@apache.org)
   * Modified by @author Rich scheuerle <sc...@us.ibm.com>
   */
  public class VectorDeserializer extends DeserializerImpl implements Deserializer  {
  
      static Category category =
              Category.getInstance(VectorDeserializer.class.getName());
  
      public int curIndex = 0;
  
      /**
       * This method is invoked after startElement when the element requires
       * deserialization (i.e. the element is not an href and the value is not nil.)
       * 
       * Simply creates 
       * @param namespace is the namespace of the element
       * @param localName is the name of the element
       * @param qName is the prefixed qname of the element
       * @param attributes are the attributes on the element...used to get the type
       * @param context is the DeserializationContext
       */
      public void onStartElement(String namespace, String localName,
                                 String qName, Attributes attributes,
                                 DeserializationContext context)
          throws SAXException {
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("enter00", "VectorDeserializer.startElement()"));
          }
          
          if (attributes.getValue(Constants.URI_CURRENT_SCHEMA_XSI,  "nil") != null) {
              return;
          }
          
          // Create a vector to hold the deserialized values.
          setValue(new java.util.Vector());
          
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("exit00", "VectorDeserializer.startElement()"));
          }
      }
      
      /**
       * onStartChild is called on each child element.
       *
       * @param namespace is the namespace of the child element
       * @param localName is the local name of the child element
       * @param prefix is the prefix used on the name of the child element
       * @param attributes are the attributes of the child element
       * @param context is the deserialization context.
       * @return is a Deserializer to use to deserialize a child (must be
       * a derived class of SOAPHandler) or null if no deserialization should
       * be performed.
       */
      public SOAPHandler onStartChild(String namespace,
                                      String localName,
                                      String prefix,
                                      Attributes attributes,
                                      DeserializationContext context)
          throws SAXException {
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("enter00", "VectorDeserializer.onStartChild()"));
          }
          
          if (attributes == null)
              throw new SAXException(JavaUtils.getMessage("noType01"));
  
          // If the xsi:nil attribute, set the value to null and return since
          // there is nothing to deserialize.
          if (context.isNil(attributes)) {
              setValue(null, new Integer(curIndex++));
              return null;
          }
  
          // Get the type
          QName itemType = context.getTypeFromAttributes(namespace,
                                                         localName,
                                                         attributes);
          if (itemType == null)
              throw new SAXException(JavaUtils.getMessage("noType01"));
          
          // Get the deserializer
          Deserializer dSer = context.getDeserializerForType(itemType);
          if (dSer == null)
              throw new SAXException(JavaUtils.getMessage("noType01"));
  
          // When the value is deserialized, inform us.
          // Need to pass the index because multi-ref stuff may 
          // result in the values being deserialized in a different order.
          dSer.registerValueTarget(new DeserializerTarget(this, new Integer(curIndex)));
          curIndex++;
  
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("exit00", "VectorDeserializer.onStartChild()"));
          }
          return (SOAPHandler) dSer;
      }
      
      /**
       * The registerValueTarget code above causes this set function to be invoked when
       * each value is known.
       * @param value is the value of an element
       * @param hint is an Integer containing the index
       */
      public void setValue(Object value, Object hint) throws SAXException
      {
          if (category.isDebugEnabled()) {
              category.debug(JavaUtils.getMessage("gotValue00", "VectorDeserializer", "" + value));
          }
          int offset = ((Integer)hint).intValue();
          Vector v = (Vector)this.value;
          
          // If the vector is too small, grow it 
          if (offset >= v.size()) {
              v.setSize(offset+1);
          }
          v.setElementAt(value, offset);
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ser/VectorDeserializerFactory.java
  
  Index: VectorDeserializerFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import java.beans.IntrospectionException;
  import java.io.IOException;
  import java.lang.reflect.Constructor;
  import java.lang.reflect.InvocationTargetException;
  
  import javax.xml.rpc.JAXRPCException;
  import javax.xml.rpc.namespace.QName;
  
  import org.apache.axis.InternalException;
  import org.apache.axis.message.SOAPHandler;
  import org.apache.axis.utils.JavaUtils;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import org.apache.axis.encoding.Serializer;
  import org.apache.axis.encoding.SerializerFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.Deserializer;
  import org.apache.axis.encoding.DeserializerFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializerImpl;
  
  /**
   * A VectorDeserializer Factory
   *
   *  @author Rich Scheuerle (scheu@us.ibm.com)
   */
  public class VectorDeserializerFactory extends BaseDeserializerFactory {
  
      public VectorDeserializerFactory(Class javaType, QName xmlType) {
          super(VectorDeserializer.class, false, xmlType, javaType); 
      }
  }