axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ow...@apache.org
Subject cvs commit: xml-axis-wsif/java/src/org/apache/wsif/providers WSIFDynamicTypeMapping.java
Date Wed, 31 Jul 2002 10:58:59 GMT
owenb       2002/07/31 03:58:59

  Modified:    java/src/org/apache/wsif/providers
                        WSIFDynamicTypeMapping.java
  Log:
  - changed from Serializable to Externalizable
  - override writeExternal and readExternal methods so that primitive type
    classes can be (de)serialized
  
  Revision  Changes    Path
  1.4       +56 -2     xml-axis-wsif/java/src/org/apache/wsif/providers/WSIFDynamicTypeMapping.java
  
  Index: WSIFDynamicTypeMapping.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/WSIFDynamicTypeMapping.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- WSIFDynamicTypeMapping.java	19 Jul 2002 15:46:30 -0000	1.3
  +++ WSIFDynamicTypeMapping.java	31 Jul 2002 10:58:59 -0000	1.4
  @@ -57,7 +57,7 @@
   
   package org.apache.wsif.providers;
   
  -import java.io.Serializable;
  +import java.io.Externalizable;
   
   import javax.xml.namespace.QName;
   
  @@ -70,10 +70,19 @@
    * @author Alekander Slominski
    * @author Owen Burroughs <owenb@apache.org>
    */
  -public class WSIFDynamicTypeMapping implements Serializable {
  +public class WSIFDynamicTypeMapping implements Externalizable {
       protected QName xmlType;
       protected Class javaType;
   
  +    /**
  +     * No args constructor required for deserialization purposes.
  +     * This constructor should not be used directly.
  +     */
  +    public WSIFDynamicTypeMapping() {
  +    	xmlType = null;
  +    	javaType = null;
  +    }
  +
       public WSIFDynamicTypeMapping(QName xmlType, Class javaType) {
           Trc.entry(this, xmlType, javaType);
           this.xmlType = xmlType;
  @@ -91,5 +100,50 @@
   
       public String toString() {
           return "QName:" + xmlType + " Class:" + javaType;
  +    }
  +
  +    /**
  +     *  Override writeExternal method to allow primitive classes to be serialized. 
  +     */
  +    public void writeExternal(java.io.ObjectOutput out)
  +        throws java.io.IOException {
  +        out.writeObject(xmlType);
  +        if (javaType.isPrimitive()) {
  +            out.writeBoolean(true);
  +            out.writeObject(javaType.getName());
  +        } else {
  +            out.writeBoolean(false);
  +            out.writeObject(javaType);
  +        }
  +
  +    }
  +    
  +    /**
  +     *  Override readExternal method to allow primitive classes to be deserialized. 
  +     */
  +    public void readExternal(java.io.ObjectInput in)
  +        throws java.io.IOException, ClassNotFoundException {
  +        xmlType = (QName) in.readObject();
  +        boolean primitive = in.readBoolean();
  +        if (primitive) {
  +            String primitiveClassName = (String) in.readObject();
  +            if (primitiveClassName.equals("int"))
  +                javaType = int.class;
  +            else if (primitiveClassName.equals("float"))
  +                javaType = float.class;
  +            else if (primitiveClassName.equals("double"))
  +                javaType = double.class;
  +            else if (primitiveClassName.equals("boolean"))
  +                javaType = boolean.class;
  +            else if (primitiveClassName.equals("long"))
  +                javaType = long.class;
  +            else if (primitiveClassName.equals("short"))
  +                javaType = short.class;
  +            else if (primitiveClassName.equals("byte"))
  +                javaType = byte.class;
  +            else if (primitiveClassName.equals("void"))
  +                javaType = void.class;
  +        } else
  +            javaType = (Class) in.readObject();
       }
   }
  
  
  

Mime
View raw message