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 ru...@apache.org on 2001/05/08 17:35:17 UTC

cvs commit: xml-axis/java/src/org/apache/axis/encoding DateSerializer.java BeanSerializer.java SOAPEncoding.java

rubys       01/05/08 08:35:16

  Modified:    java/src/org/apache/axis/encoding BeanSerializer.java
                        SOAPEncoding.java
  Added:       java/src/org/apache/axis/encoding DateSerializer.java
  Log:
  Should have added this the first time...
  
  Revision  Changes    Path
  1.2       +1 -0      xml-axis/java/src/org/apache/axis/encoding/BeanSerializer.java
  
  Index: BeanSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/BeanSerializer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BeanSerializer.java	2001/05/07 02:20:58	1.1
  +++ BeanSerializer.java	2001/05/08 15:35:05	1.2
  @@ -219,6 +219,7 @@
                   context.serialize(new QName("", propName), null, propValue);
               }
           } catch (Exception e) {
  +        e.printStackTrace();
               throw new IOException(e.toString());
           }
   
  
  
  
  1.4       +6 -0      xml-axis/java/src/org/apache/axis/encoding/SOAPEncoding.java
  
  Index: SOAPEncoding.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/SOAPEncoding.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SOAPEncoding.java	2001/05/04 06:09:50	1.3
  +++ SOAPEncoding.java	2001/05/08 15:35:07	1.4
  @@ -5,8 +5,10 @@
   import org.apache.axis.utils.QName;
   import org.apache.axis.utils.XMLUtils;
   import org.apache.axis.Constants;
  +import java.util.Date;
   import java.util.Hashtable;
   import java.io.IOException;
  +import java.math.BigDecimal;
   
   public class SOAPEncoding implements Serializer { 
       private Hashtable typemap = new Hashtable();
  @@ -20,6 +22,8 @@
           typemap.put(Integer.class, SOAPTypeMappingRegistry.XSD_INT);
           typemap.put(Long.class,    SOAPTypeMappingRegistry.XSD_LONG);
           typemap.put(Short.class,   SOAPTypeMappingRegistry.XSD_SHORT);
  +        typemap.put(BigDecimal.class, SOAPTypeMappingRegistry.XSD_DECIMAL);
  +        typemap.put(Date.class,    SOAPTypeMappingRegistry.XSD_DATE);
           namemap.put(String.class,  SOAPTypeMappingRegistry.SOAP_STRING);
           namemap.put(Boolean.class, SOAPTypeMappingRegistry.SOAP_BOOLEAN);
           namemap.put(Double.class,  SOAPTypeMappingRegistry.SOAP_DOUBLE);
  @@ -27,6 +31,8 @@
           namemap.put(Integer.class, SOAPTypeMappingRegistry.SOAP_INT);
           namemap.put(Long.class,    SOAPTypeMappingRegistry.SOAP_LONG);
           namemap.put(Short.class,   SOAPTypeMappingRegistry.SOAP_SHORT);
  +        namemap.put(BigDecimal.class, SOAPTypeMappingRegistry.XSD_DECIMAL);
  +        namemap.put(Date.class,    SOAPTypeMappingRegistry.XSD_DATE);
       }
       
       public void serialize(QName qname, Attributes attributes,
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/encoding/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;
  
  import java.io.IOException;
  import java.text.SimpleDateFormat;
  import java.util.TimeZone;
  import java.util.Date;
  import java.text.DateFormat;
  
  import org.apache.axis.encoding.*;
  import org.apache.axis.utils.QName;
  
  import org.xml.sax.*;
  
  /**
   * General purpose serializer/deserializerFactory for an arbitrary java bean.
   *
   * @author Sam Ruby <ru...@us.ibm.com>
   */
  public class DateSerializer implements Serializer {
  
      static SimpleDateFormat zulu = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SSS'Z'");
  
      static {
        zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
      }
  
      static class DateDeser extends SOAPTypeMappingRegistry.BasicDeser {
          Object makeValue(String source) { 
            try {
              return DateFormat.getDateInstance().parse(source); 
            } catch (Exception e) {
              throw new NumberFormatException(e.toString());
            }
          }
      }
  
      static public class DateDeserializerFactory implements DeserializerFactory {
          public DeserializerBase getDeserializer() { return new DateDeser(); }
      }
  
      /** 
       * Serialize a date.
       */
      public void serialize(QName name, Attributes attributes,
                            Object value, SerializationContext context)
          throws IOException
      {
          context.startElement(name, attributes);
          context.writeString(zulu.format((Date)value));
          context.endElement();
      }
  }