commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmi...@apache.org
Subject cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/util TypeUtils.java
Date Wed, 08 May 2002 23:03:43 GMT
dmitri      02/05/08 16:03:43

  Modified:    jxpath/src/java/org/apache/commons/jxpath/util
                        TypeUtils.java
  Log:
  Added conversion from null to primitive
  
  Revision  Changes    Path
  1.6       +30 -4     jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/util/TypeUtils.java
  
  Index: TypeUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/util/TypeUtils.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TypeUtils.java	8 May 2002 00:38:19 -0000	1.5
  +++ TypeUtils.java	8 May 2002 23:03:43 -0000	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/util/TypeUtils.java,v
1.5 2002/05/08 00:38:19 dmitri Exp $
  - * $Revision: 1.5 $
  - * $Date: 2002/05/08 00:38:19 $
  + * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/util/TypeUtils.java,v
1.6 2002/05/08 23:03:43 dmitri Exp $
  + * $Revision: 1.6 $
  + * $Date: 2002/05/08 23:03:43 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -70,7 +70,7 @@
   
   /**
    * @author Dmitri Plotnikov
  - * @version $Revision: 1.5 $ $Date: 2002/05/08 00:38:19 $
  + * @version $Revision: 1.6 $ $Date: 2002/05/08 23:03:43 $
    */
   public class TypeUtils {
   
  @@ -418,6 +418,32 @@
   
       public static Object convert(Object object, Class toType){
           if (object == null){
  +            if (toType.isPrimitive()){
  +                if (toType == boolean.class){
  +                    return Boolean.FALSE;
  +                }
  +                if (toType == char.class){
  +                    return new Character('\0');
  +                }
  +                if (toType == byte.class){
  +                    return new Byte((byte)0);
  +                }
  +                if (toType == short.class){
  +                    return new Short((short)0);
  +                }
  +                if (toType == int.class){
  +                    return new Integer(0);
  +                }
  +                if (toType == long.class){
  +                    return new Long(0l);
  +                }
  +                if (toType == float.class){
  +                    return new Float(0.0f);
  +                }
  +                if (toType == double.class){
  +                    return new Double(0.0);
  +                }
  +            }
               return null;
           }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message