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 gd...@apache.org on 2001/04/27 01:03:08 UTC

cvs commit: xml-axis/java/src/org/apache/axis/encoding DeserializationContext.java DeserializerBase.java SerializationContext.java ServiceDescription.java TypeMapper.java Serializer.java Deserializer.java TypeMappingRegistry.java

gdaniels    01/04/26 16:03:08

  Modified:    java/src/org/apache/axis/encoding Serializer.java
  Added:       java/src/org/apache/axis/encoding
                        DeserializationContext.java DeserializerBase.java
                        SerializationContext.java ServiceDescription.java
                        TypeMapper.java
  Removed:     java/src/org/apache/axis/encoding Deserializer.java
                        TypeMappingRegistry.java
  Log:
  1st cut at new encoding system.  Needs work!
  
  This includes the (raw) beginnings of a service description framework,
  which will hopefully be an abstract framework for understanding the
  types of various parts of a message.  An implementation of this
  framework would handle WSDL.
  
  Revision  Changes    Path
  1.2       +1 -6      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Serializer.java	2001/03/25 08:56:40	1.1
  +++ Serializer.java	2001/04/26 23:03:08	1.2
  @@ -55,16 +55,11 @@
   
   package org.apache.axis.encoding;
   
  -import org.apache.axis.message.Message;
  -import org.apache.axis.message.MessageElement;
  -import org.apache.axis.utils.QName;
  -import org.apache.axis.utils.NSStack;
  -
   /**
    * @author James Snell (jasnell@us.ibm.com)
    */
   public interface Serializer { 
       
  -    public MessageElement serialize(QName name, Object value, NSStack nsStack, TypeMappingRegistry tmr, Message message);
  +    //public MessageElement serialize(QName name, Object value, NSStack nsStack, TypeMappingRegistry tmr, Message message);
       
   }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/DeserializationContext.java
  
  Index: DeserializationContext.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.xml.sax.*;
  import java.util.*;
  import org.apache.axis.encoding.*;
  import org.apache.axis.message.*;
  import org.apache.axis.utils.QName;
  
  /** Keeps track of the active typeMappings, element IDs, parser, and
   * SOAPSAXHandler in an ongoing parse.  Might want to move the
   * storage for the namespace/prefix mappings into here too...
   * 
   * @author Glen Daniels (gdaniels@allaire.com)
   */
  
  public class DeserializationContext
  {
      public SOAPSAXHandler baseHandler;
      public Hashtable idMappings = new Hashtable();
      public TypeMapper typeMappings = new TypeMapper();
      
      public DeserializationContext(SOAPSAXHandler baseHandler)
      {
          this.baseHandler = baseHandler;
      }
      
      public void pushElementHandler(ContentHandler handler)
      {
          baseHandler.pushElementHandler(handler);    
      }
      
      public String getNamespaceURI(String prefix)
      {
          return (String)baseHandler.getNamespaceURI(prefix);
      }
      
      public void registerID(String id, MessageElement element)
      {
          // Throw an exception if already registered?
          idMappings.put(id, element);
      }
      
      public MessageElement getElementByID(String id)
      {
          return (MessageElement)idMappings.get(id);
      }
      
      public DeserializerBase getDeserializer(QName qName)
      {
          return typeMappings.getDeserializer(qName);
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/DeserializerBase.java
  
  Index: DeserializerBase.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.xml.sax.*;
  import org.xml.sax.helpers.*;
  
  /** A convenience base class for deserializers, which handles throwing
   * exceptions when unexpected events occur.
   * 
   * !!! Can probably simplify this by just having all methods throw in
   * here, then people can just overload what they allow.
   * 
   * The "value" object needs to be kept somewhere.  We can either do it
   * here, which necessitates a deserializer instance for each deserialization,
   * or could somehow store the state in the MessageElement which is
   * being blessed with a value.  Might bear some investigating.
   * 
   * @author Glen Daniels (gdaniels@allaire.com)
   */
  
  public class DeserializerBase extends DefaultHandler
  {
      public static long STARTDOCUMENT  = 0x0002;
      public static long ENDDOCUMENT    = 0x0004;
      public static long STARTPREFIXMAP = 0x0008;
      public static long ENDPREFIXMAP   = 0x0010;
      public static long STARTELEMENT   = 0x0020;
      public static long ENDELEMENT     = 0x0040;
      public static long CHARACTERS     = 0x0080;
      public static long WHITESPACE     = 0x0100;
      public static long SKIPPEDENTITY  = 0x0200;
      public static long PROCESSINGINST = 0x0400;
      
      private long allowedEvents = 0;
      protected Object value = null;
      
      public Object getValue()
      {
          return value;
      }
      
      protected void setAllowedEvents(long mask)
      {
          allowedEvents = mask;
      }
      
      public void startDocument() throws SAXException {
          if ((allowedEvents & STARTDOCUMENT) == 0)
              throw new SAXException(
                  "StartDocument event not allowed in this context.");
      }
      
      public void endDocument() throws SAXException {
          if ((allowedEvents & ENDDOCUMENT) == 0)
              throw new SAXException(
                  "EndDocument event not allowed in this context.");
      }
      
      public void startPrefixMapping(String p1, String p2) throws SAXException {
          if ((allowedEvents & STARTPREFIXMAP) == 0)
              throw new SAXException(
                  "StartPrefixMapping event not allowed in this context.");
      }
      
      public void endPrefixMapping(String p1) throws SAXException {
          if ((allowedEvents & ENDPREFIXMAP) == 0)
              throw new SAXException(
                  "EndPrefixMapping event not allowed in this context.");
      }
      
      public void characters(char[] p1, int p2, int p3) throws SAXException {
          if ((allowedEvents & CHARACTERS) == 0)
              throw new SAXException(
                  "Characters event not allowed in this context.");
      }
      
      public void ignorableWhitespace(char[] p1, int p2, int p3) 
          throws SAXException
      {
          if ((allowedEvents & WHITESPACE) == 0)
              throw new SAXException(
                  "IgnorableWhitespace event not allowed in this context.");
      }
   
      public void skippedEntity(String p1) throws SAXException {
          if ((allowedEvents & SKIPPEDENTITY) == 0)
              throw new SAXException(
                  "SkippedEntity event not allowed in this context.");
      }
      
      public void startElement(String namespace, String localName,
                               String qName, Attributes attributes)
          throws SAXException
      {
          if ((allowedEvents & STARTELEMENT) == 0)
              throw new SAXException(
                  "StartElement event not allowed in this context.");
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/SerializationContext.java
  
  Index: SerializationContext.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 java.io.*;
  import java.util.*;
  import org.xml.sax.*;
  import org.xml.sax.helpers.AttributesImpl;
  import org.apache.axis.message.*;
  import org.apache.axis.utils.*;
  
  /** Manage a serialization, including keeping track of namespace mappings
   * and element stacks.
   * 
   * WARNING : HIGHLY PRELIMINARY!!!
   * 
   * @author Glen Daniels (gdaniels@macromedia.com)
   */
  public class SerializationContext
  {
      private static final boolean DEBUG_LOG = false;
      
      public NSStack nsStack = new NSStack();
                                          
      public Hashtable pendingNSMappings = new Hashtable();
      boolean writingStartTag = false;
      
      Stack elementStack = new Stack();
      Writer writer;
      
      int lastPrefixIndex = 1;
      
      TypeMapper typeMapper = new TypeMapper();
      
      public SerializationContext(Writer writer)
      {
          this.writer = writer;
      }
      
      public String getPrefixForURI(String uri)
      {
          String prefix = nsStack.getPrefix(uri);
          
          if (prefix == null)
              prefix = (String)pendingNSMappings.get(uri);
          
          if (prefix == null) {
              prefix = "ns" + lastPrefixIndex++;
              registerPrefixForURI(prefix, uri);
          }
          
          return prefix;
      }
      
      public void registerPrefixForURI(String prefix, String uri)
      {
          if (DEBUG_LOG) {
              System.out.println("register '" + prefix + "' - '" + uri + "'");
          }
          
          if ((uri != null) && (prefix != null) && !prefix.equals("") &&
              !uri.equals("")) {
              if ((pendingNSMappings.get(uri) != null) ||
                  (nsStack.getPrefix(uri) != null))
                  return;
              
              pendingNSMappings.put(uri, prefix);
          }
      }
      
      public String qName2String(QName qName)
      {
          return getPrefixForURI(qName.getNamespaceURI()) +
                 ":" +
                 qName.getLocalPart();
      }
      
      public QName getQNameForClass(Class cls)
      {
          return typeMapper.getTypeQName(cls);
      }
      
      public void startElement(QName qName, Attributes attributes)
          throws IOException
      {
          if (writingStartTag) {
              writer.write(">");
          }
          
          String nsURI = qName.getNamespaceURI();
          
          if (!pendingNSMappings.isEmpty()) {
              nsStack.push((Hashtable)pendingNSMappings.clone());
          } else {
              nsStack.push();
          }
          
          //nsStack.dump();
          
          String elementQName;
          StringBuffer buf = new StringBuffer();
          buf.append("<");
          
          if ((nsURI != null) && (!nsURI.equals(""))) {
              elementQName = nsStack.getPrefix(nsURI) + ":";
          } else {
              elementQName = "";
          }
          elementQName += qName.getLocalPart();
          buf.append(elementQName);
          
          if (attributes != null) {
              for (int i = 0; i < attributes.getLength(); i++) {
                  buf.append(" " + attributes.getQName(i) + "=\"" +
                             attributes.getValue(i) +"\"");
              }
          }
          
          Enumeration e = pendingNSMappings.keys();
          while (e.hasMoreElements()) {
              String uri = (String)e.nextElement();
              String pref = (String)pendingNSMappings.get(uri);
              buf.append(" xmlns:" + pref + "=\"" + uri + "\"");
          }
  
          writingStartTag = true;
          
          elementStack.push(elementQName);
          
          pendingNSMappings.clear();
          
          writer.write(buf.toString());
          writer.flush();
      }
      
      public void endElement()
          throws IOException
      {
          String elementQName = (String)elementStack.pop();
          nsStack.pop();
  
          if (writingStartTag) {
              writer.write("/>");
              writingStartTag = false;
              return;
          }
          
          StringBuffer buf = new StringBuffer();
          buf.append("</" + elementQName + ">");
          writer.write(buf.toString());
          writer.flush();
      }
      
      public void writeChars(char [] p1, int p2, int p3)
          throws IOException
      {
          if (writingStartTag) {
              writer.write(">");
              writingStartTag = false;
          }
          writer.write(p1, p2, p3);
          writer.flush();
      }
  
      public void writeString(String string)
          throws IOException
      {
          if (writingStartTag) {
              writer.write(">");
              writingStartTag = false;
          }
          writer.write(string);
          writer.flush();
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/ServiceDescription.java
  
  Index: ServiceDescription.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 java.util.*;
  import org.apache.axis.utils.QName;
  
  /** A very simple service description class, to demonstrate one way
   * to get type information out of band.
   * 
   * !!! This wants to be extended beyond just RPC... get away from
   * the focus on Parameters, and just type arbitrarily named
   * elements, hook up with schema systems, build an adapter for
   * parsing types using Castor, etc...  So we probably want to
   * migrate the type mapping stuff into here.
   * 
   * @author Glen Daniels (gdaniels@macromedia.com)
   */
  public class ServiceDescription
  {
      public static final String REQUEST = "Request";
      public static final String RESPONSE = "Response";
      
      String name;
      
      class Param {
          public String name;
          public QName type;
          Param(String name, QName type)
          {
              this.name = name;
              this.type = type;
          }
          Param() {}
      }
      
      /** This probably wants to be split into a WSDL-like
       * set of MessageDescription objects, each of which
       * may then have named parts... that would allow
       * supporting arbitrary message patterns, too.
       * 
       * this is just a tiny demo for req/resp RPC.
       */
      public Vector inputParams = new Vector();
      public Vector outputParams = new Vector();
      
      // Should we tack on "xsi:type" attributes?
      public boolean sendXsiType = true;
      
      public ServiceDescription(String name)
      {
          this.name = name;
      }
      
      public void addInputParam(String name, QName type)
      {
          inputParams.addElement(new Param(name, type));
      }
      
      public void addOutputParam(String name, QName type)
      {
          outputParams.addElement(new Param(name, type));
      }
      
      public void setSendTypeAttr(boolean sendType)
      {
          sendXsiType = sendType;
      }
      
      public boolean getSendTypeAttr()
      {
          return sendXsiType;
      }
      
      Param findByName(String name, Vector list)
      {
          Enumeration e = list.elements();
          while (e.hasMoreElements()) {
              Param p = (Param)e.nextElement();
              if (p.name.equals(name))
                  return p;
          }
          
          return null;
      }
  
      public QName getInputParamTypeByName(String paramName)
      {
          Param param = findByName(paramName, inputParams);
          if (param != null)
              return param.type;
          return null;
      }
      
      public QName getInputParamTypeByPos(int position)
      {
          Param param = (Param)inputParams.elementAt(position);
          if (param != null)
              return param.type;
          return null;
      }
      
      /** This one is what the outside world wants to use, I think.
       */
      public QName getParamTypeByName(String messageType, String paramName)
      {
          System.out.println("[" + messageType + "] - " + paramName);
          
          if (messageType.equals(REQUEST))
              return getInputParamTypeByName(paramName);
          if (messageType.equals(RESPONSE))
              return getOutputParamTypeByName(paramName);
          
          // Only understand these two at present...
          
          return null;
      }
      
      public QName getOutputParamTypeByName(String paramName)
      {
          Param param = findByName(paramName, outputParams);
          if (param != null)
              return param.type;
          return null;
      }
      
      public QName getOutputParamTypeByPos(int position)
      {
          Param param = (Param)outputParams.elementAt(position);
          if (param != null)
              return param.type;
          return null;
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/TypeMapper.java
  
  Index: TypeMapper.java
  ===================================================================
  package org.apache.axis.encoding;
  
  import org.apache.axis.utils.QName;
  import org.apache.axis.Constants;
  import java.util.*;
  
  /** A quick stab at a SAX-based type mapper/deserializer infrastructure.
   * 
   * !!! THIS IS HIGHLY PRELIMINARY, and needs to be turned into something
   * much more real.
   * 
   * @author Glen Daniels (gdaniels@macromedia.com)
   */
  public class TypeMapper
  {
      interface DeserFactory {
          public BasicDeser getDeser();
      }
  
      abstract class BasicDeser extends DeserializerBase {
          BasicDeser() { setAllowedEvents(CHARACTERS); }
          
          public void characters(char [] chars, int start, int end)
          {
              System.out.print("BasicDeser parsing chars...");
              value = makeValue(new String(chars, start, end));
              System.out.println("val is [" + value + "]");
          }
          abstract Object makeValue(String source);
      }
      class IntDeser extends BasicDeser {
          Object makeValue(String source) { return new Integer(source); }
      }
      class IntDeserFactory implements DeserFactory {
          public BasicDeser getDeser() { return new IntDeser(); }
      }
      class LongDeser extends BasicDeser {
          Object makeValue(String source) { return new Long(source); }
      }
      class LongDeserFactory implements DeserFactory {
          public BasicDeser getDeser() { return new LongDeser(); }
      }
      class StringDeser extends BasicDeser {
          Object makeValue(String source) { return source; };
      }
      class StringDeserFactory implements DeserFactory {
          public BasicDeser getDeser() { return new StringDeser(); }
      }
      
      Hashtable deserializers = new Hashtable();
      Hashtable serializers = new Hashtable();
                                            
      public void registerDeserializer(QName qName, DeserFactory factory)
      {
          deserializers.put(qName, factory);
      }
      
      public void registerSerializer(Class cls, QName qName, Serializer serializer)
      {
          serializers.put(cls, serializer);
      }
      
      public TypeMapper()
      {
          registerDeserializer(new QName(Constants.URI_SCHEMA_XSD, "int"), new IntDeserFactory());
          registerDeserializer(new QName(Constants.URI_SCHEMA_XSD, "long"), new LongDeserFactory());
          registerDeserializer(new QName(Constants.URI_SCHEMA_XSD, "string"), new StringDeserFactory());
      }
      
      public DeserializerBase getDeserializer(QName qName)
      {
          System.out.print("Getting deserializer...");
          Enumeration e = deserializers.keys();
          while (e.hasMoreElements()) {
              QName keyQName = (QName)e.nextElement();
              if (keyQName.equals(qName)) {
                  System.out.println("got it.");
                  return ((DeserFactory)deserializers.get(keyQName)).getDeser();
              }
          }
          
          System.out.println("didn't find one.");
          return null;
      }
      
      public QName getTypeQName(Class cls)
      {
          if (cls.equals(String.class)) {
              return new QName(Constants.URI_SCHEMA_XSD, "string");
          }
          
          return null;
      }
  }