commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject cvs commit: jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters BigDecimalConverter.java BigIntegerConverter.java BooleanConverter.java ByteConverter.java CharacterConverter.java DoubleConverter.java FloatConverter.java IntegerConverter.java LongConverter.java ShortConverter.java SqlDateConverter.java SqlTimeConverter.java SqlTimestampConverter.java
Date Thu, 11 Apr 2002 19:50:06 GMT
craigmcc    02/04/11 12:50:06

  Modified:    beanutils/src/java/org/apache/commons/beanutils/converters
                        BigDecimalConverter.java BigIntegerConverter.java
                        BooleanConverter.java ByteConverter.java
                        CharacterConverter.java DoubleConverter.java
                        FloatConverter.java IntegerConverter.java
                        LongConverter.java ShortConverter.java
                        SqlDateConverter.java SqlTimeConverter.java
                        SqlTimestampConverter.java
  Log:
  Make it possible to specify a default value of null for return on
  conversion errors.
  
  Revision  Changes    Path
  1.2       +15 -7     jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/BigDecimalConverter.java
  
  Index: BigDecimalConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/BigDecimalConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BigDecimalConverter.java	18 Mar 2002 16:32:43 -0000	1.1
  +++ BigDecimalConverter.java	11 Apr 2002 19:50:06 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/BigDecimalConverter.java,v
1.1 2002/03/18 16:32:43 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/03/18 16:32:43 $
  + * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/BigDecimalConverter.java,v
1.2 2002/04/11 19:50:06 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/11 19:50:06 $
    *
    * ====================================================================
    *
  @@ -75,7 +75,7 @@
    * error occurs.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2002/03/18 16:32:43 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/11 19:50:06 $
    * @since 1.3
    */
   
  @@ -91,7 +91,8 @@
        */
       public BigDecimalConverter() {
   
  -        this(null);
  +        this.defaultValue = null;
  +        this.useDefault = false;
   
       }
   
  @@ -105,6 +106,7 @@
       public BigDecimalConverter(Object defaultValue) {
   
           this.defaultValue = defaultValue;
  +        this.useDefault = true;
   
       }
   
  @@ -118,6 +120,12 @@
       private Object defaultValue = null;
   
   
  +    /**
  +     * Should we return the default value on conversion errors?
  +     */
  +    private boolean useDefault = true;
  +
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -134,7 +142,7 @@
       public Object convert(Class type, Object value) {
   
           if (value == null) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException("No value specified");
  @@ -144,7 +152,7 @@
           try {
               return (new BigDecimal((String) value));
           } catch (Exception e) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException(e);
  
  
  
  1.2       +15 -7     jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/BigIntegerConverter.java
  
  Index: BigIntegerConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/BigIntegerConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BigIntegerConverter.java	18 Mar 2002 16:32:43 -0000	1.1
  +++ BigIntegerConverter.java	11 Apr 2002 19:50:06 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/BigIntegerConverter.java,v
1.1 2002/03/18 16:32:43 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/03/18 16:32:43 $
  + * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/BigIntegerConverter.java,v
1.2 2002/04/11 19:50:06 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/11 19:50:06 $
    *
    * ====================================================================
    *
  @@ -75,7 +75,7 @@
    * error occurs.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2002/03/18 16:32:43 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/11 19:50:06 $
    * @since 1.3
    */
   
  @@ -91,7 +91,8 @@
        */
       public BigIntegerConverter() {
   
  -        this(null);
  +        this.defaultValue = null;
  +        this.useDefault = false;
   
       }
   
  @@ -105,6 +106,7 @@
       public BigIntegerConverter(Object defaultValue) {
   
           this.defaultValue = defaultValue;
  +        this.useDefault = true;
   
       }
   
  @@ -118,6 +120,12 @@
       private Object defaultValue = null;
   
   
  +    /**
  +     * Should we return the default value on conversion errors?
  +     */
  +    private boolean useDefault = true;
  +
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -134,7 +142,7 @@
       public Object convert(Class type, Object value) {
   
           if (value == null) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException("No value specified");
  @@ -144,7 +152,7 @@
           try {
               return (new BigInteger((String) value));
           } catch (Exception e) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException(e);
  
  
  
  1.2       +16 -8     jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/BooleanConverter.java
  
  Index: BooleanConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/BooleanConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BooleanConverter.java	18 Mar 2002 16:32:43 -0000	1.1
  +++ BooleanConverter.java	11 Apr 2002 19:50:06 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/BooleanConverter.java,v
1.1 2002/03/18 16:32:43 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/03/18 16:32:43 $
  + * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/BooleanConverter.java,v
1.2 2002/04/11 19:50:06 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/11 19:50:06 $
    *
    * ====================================================================
    *
  @@ -74,7 +74,7 @@
    * error occurs.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2002/03/18 16:32:43 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/11 19:50:06 $
    * @since 1.3
    */
   
  @@ -90,7 +90,8 @@
        */
       public BooleanConverter() {
   
  -        this(null);
  +        this.defaultValue = null;
  +        this.useDefault = false;
   
       }
   
  @@ -104,6 +105,7 @@
       public BooleanConverter(Object defaultValue) {
   
           this.defaultValue = defaultValue;
  +        this.useDefault = true;
   
       }
   
  @@ -117,6 +119,12 @@
       private Object defaultValue = null;
   
   
  +    /**
  +     * Should we return the default value on conversion errors?
  +     */
  +    private boolean useDefault = true;
  +
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -133,7 +141,7 @@
       public Object convert(Class type, Object value) {
   
           if (value == null) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException("No value specified");
  @@ -150,13 +158,13 @@
                          stringValue.equalsIgnoreCase("false") ||
                          stringValue.equalsIgnoreCase("off")) {
                   return (Boolean.FALSE);
  -            } else if (defaultValue != null) {
  +            } else if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException(stringValue);
               }
           } catch (ClassCastException e) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException(e);
  
  
  
  1.2       +15 -7     jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/ByteConverter.java
  
  Index: ByteConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/ByteConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ByteConverter.java	18 Mar 2002 16:32:43 -0000	1.1
  +++ ByteConverter.java	11 Apr 2002 19:50:06 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/ByteConverter.java,v
1.1 2002/03/18 16:32:43 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/03/18 16:32:43 $
  + * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/ByteConverter.java,v
1.2 2002/04/11 19:50:06 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/11 19:50:06 $
    *
    * ====================================================================
    *
  @@ -74,7 +74,7 @@
    * error occurs.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2002/03/18 16:32:43 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/11 19:50:06 $
    * @since 1.3
    */
   
  @@ -90,7 +90,8 @@
        */
       public ByteConverter() {
   
  -        this(null);
  +        this.defaultValue = null;
  +        this.useDefault = false;
   
       }
   
  @@ -104,6 +105,7 @@
       public ByteConverter(Object defaultValue) {
   
           this.defaultValue = defaultValue;
  +        this.useDefault = true;
   
       }
   
  @@ -117,6 +119,12 @@
       private Object defaultValue = null;
   
   
  +    /**
  +     * Should we return the default value on conversion errors?
  +     */
  +    private boolean useDefault = true;
  +
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -133,7 +141,7 @@
       public Object convert(Class type, Object value) {
   
           if (value == null) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException("No value specified");
  @@ -143,7 +151,7 @@
           try {
               return (new Byte((String) value));
           } catch (Exception e) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException(e);
  
  
  
  1.2       +15 -7     jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/CharacterConverter.java
  
  Index: CharacterConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/CharacterConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CharacterConverter.java	18 Mar 2002 16:32:43 -0000	1.1
  +++ CharacterConverter.java	11 Apr 2002 19:50:06 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/CharacterConverter.java,v
1.1 2002/03/18 16:32:43 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/03/18 16:32:43 $
  + * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/CharacterConverter.java,v
1.2 2002/04/11 19:50:06 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/11 19:50:06 $
    *
    * ====================================================================
    *
  @@ -74,7 +74,7 @@
    * error occurs.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2002/03/18 16:32:43 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/11 19:50:06 $
    * @since 1.3
    */
   
  @@ -90,7 +90,8 @@
        */
       public CharacterConverter() {
   
  -        this(null);
  +        this.defaultValue = null;
  +        this.useDefault = false;
   
       }
   
  @@ -104,6 +105,7 @@
       public CharacterConverter(Object defaultValue) {
   
           this.defaultValue = defaultValue;
  +        this.useDefault = true;
   
       }
   
  @@ -117,6 +119,12 @@
       private Object defaultValue = null;
   
   
  +    /**
  +     * Should we return the default value on conversion errors?
  +     */
  +    private boolean useDefault = true;
  +
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -133,7 +141,7 @@
       public Object convert(Class type, Object value) {
   
           if (value == null) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException("No value specified");
  @@ -143,7 +151,7 @@
           try {
               return (new Character(((String) value).charAt(0)));
           } catch (Exception e) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException(e);
  
  
  
  1.2       +15 -7     jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/DoubleConverter.java
  
  Index: DoubleConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/DoubleConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DoubleConverter.java	18 Mar 2002 16:32:43 -0000	1.1
  +++ DoubleConverter.java	11 Apr 2002 19:50:06 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/DoubleConverter.java,v
1.1 2002/03/18 16:32:43 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/03/18 16:32:43 $
  + * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/DoubleConverter.java,v
1.2 2002/04/11 19:50:06 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/11 19:50:06 $
    *
    * ====================================================================
    *
  @@ -74,7 +74,7 @@
    * error occurs.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2002/03/18 16:32:43 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/11 19:50:06 $
    * @since 1.3
    */
   
  @@ -90,7 +90,8 @@
        */
       public DoubleConverter() {
   
  -        this(null);
  +        this.defaultValue = null;
  +        this.useDefault = false;
   
       }
   
  @@ -104,6 +105,7 @@
       public DoubleConverter(Object defaultValue) {
   
           this.defaultValue = defaultValue;
  +        this.useDefault = true;
   
       }
   
  @@ -117,6 +119,12 @@
       private Object defaultValue = null;
   
   
  +    /**
  +     * Should we return the default value on conversion errors?
  +     */
  +    private boolean useDefault = true;
  +
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -133,7 +141,7 @@
       public Object convert(Class type, Object value) {
   
           if (value == null) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException("No value specified");
  @@ -143,7 +151,7 @@
           try {
               return (new Double((String) value));
           } catch (Exception e) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException(e);
  
  
  
  1.2       +15 -7     jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/FloatConverter.java
  
  Index: FloatConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/FloatConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FloatConverter.java	18 Mar 2002 16:32:43 -0000	1.1
  +++ FloatConverter.java	11 Apr 2002 19:50:06 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/FloatConverter.java,v
1.1 2002/03/18 16:32:43 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/03/18 16:32:43 $
  + * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/FloatConverter.java,v
1.2 2002/04/11 19:50:06 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/11 19:50:06 $
    *
    * ====================================================================
    *
  @@ -74,7 +74,7 @@
    * error occurs.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2002/03/18 16:32:43 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/11 19:50:06 $
    * @since 1.3
    */
   
  @@ -90,7 +90,8 @@
        */
       public FloatConverter() {
   
  -        this(null);
  +        this.defaultValue = null;
  +        this.useDefault = false;
   
       }
   
  @@ -104,6 +105,7 @@
       public FloatConverter(Object defaultValue) {
   
           this.defaultValue = defaultValue;
  +        this.useDefault = true;
   
       }
   
  @@ -117,6 +119,12 @@
       private Object defaultValue = null;
   
   
  +    /**
  +     * Should we return the default value on conversion errors?
  +     */
  +    private boolean useDefault = true;
  +
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -133,7 +141,7 @@
       public Object convert(Class type, Object value) {
   
           if (value == null) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException("No value specified");
  @@ -143,7 +151,7 @@
           try {
               return (new Float((String) value));
           } catch (Exception e) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException(e);
  
  
  
  1.2       +15 -7     jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/IntegerConverter.java
  
  Index: IntegerConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/IntegerConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IntegerConverter.java	18 Mar 2002 16:32:43 -0000	1.1
  +++ IntegerConverter.java	11 Apr 2002 19:50:06 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/IntegerConverter.java,v
1.1 2002/03/18 16:32:43 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/03/18 16:32:43 $
  + * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/IntegerConverter.java,v
1.2 2002/04/11 19:50:06 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/11 19:50:06 $
    *
    * ====================================================================
    *
  @@ -74,7 +74,7 @@
    * error occurs.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2002/03/18 16:32:43 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/11 19:50:06 $
    * @since 1.3
    */
   
  @@ -90,7 +90,8 @@
        */
       public IntegerConverter() {
   
  -        this(null);
  +        this.defaultValue = null;
  +        this.useDefault = false;
   
       }
   
  @@ -104,6 +105,7 @@
       public IntegerConverter(Object defaultValue) {
   
           this.defaultValue = defaultValue;
  +        this.useDefault = true;
   
       }
   
  @@ -117,6 +119,12 @@
       private Object defaultValue = null;
   
   
  +    /**
  +     * Should we return the default value on conversion errors?
  +     */
  +    private boolean useDefault = true;
  +
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -133,7 +141,7 @@
       public Object convert(Class type, Object value) {
   
           if (value == null) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException("No value specified");
  @@ -143,7 +151,7 @@
           try {
               return (new Integer((String) value));
           } catch (Exception e) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException(e);
  
  
  
  1.2       +15 -7     jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/LongConverter.java
  
  Index: LongConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/LongConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LongConverter.java	18 Mar 2002 16:32:43 -0000	1.1
  +++ LongConverter.java	11 Apr 2002 19:50:06 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/LongConverter.java,v
1.1 2002/03/18 16:32:43 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/03/18 16:32:43 $
  + * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/LongConverter.java,v
1.2 2002/04/11 19:50:06 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/11 19:50:06 $
    *
    * ====================================================================
    *
  @@ -74,7 +74,7 @@
    * error occurs.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2002/03/18 16:32:43 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/11 19:50:06 $
    * @since 1.3
    */
   
  @@ -90,7 +90,8 @@
        */
       public LongConverter() {
   
  -        this(null);
  +        this.defaultValue = null;
  +        this.useDefault = false;
   
       }
   
  @@ -104,6 +105,7 @@
       public LongConverter(Object defaultValue) {
   
           this.defaultValue = defaultValue;
  +        this.useDefault = true;
   
       }
   
  @@ -117,6 +119,12 @@
       private Object defaultValue = null;
   
   
  +    /**
  +     * Should we return the default value on conversion errors?
  +     */
  +    private boolean useDefault = true;
  +
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -133,7 +141,7 @@
       public Object convert(Class type, Object value) {
   
           if (value == null) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException("No value specified");
  @@ -143,7 +151,7 @@
           try {
               return (new Long((String) value));
           } catch (Exception e) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException(e);
  
  
  
  1.2       +15 -7     jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/ShortConverter.java
  
  Index: ShortConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/ShortConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ShortConverter.java	18 Mar 2002 16:32:43 -0000	1.1
  +++ ShortConverter.java	11 Apr 2002 19:50:06 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/ShortConverter.java,v
1.1 2002/03/18 16:32:43 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/03/18 16:32:43 $
  + * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/ShortConverter.java,v
1.2 2002/04/11 19:50:06 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/11 19:50:06 $
    *
    * ====================================================================
    *
  @@ -74,7 +74,7 @@
    * error occurs.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2002/03/18 16:32:43 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/11 19:50:06 $
    * @since 1.3
    */
   
  @@ -90,7 +90,8 @@
        */
       public ShortConverter() {
   
  -        this(null);
  +        this.defaultValue = null;
  +        this.useDefault = false;
   
       }
   
  @@ -104,6 +105,7 @@
       public ShortConverter(Object defaultValue) {
   
           this.defaultValue = defaultValue;
  +        this.useDefault = true;
   
       }
   
  @@ -117,6 +119,12 @@
       private Object defaultValue = null;
   
   
  +    /**
  +     * Should we return the default value on conversion errors?
  +     */
  +    private boolean useDefault = true;
  +
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -133,7 +141,7 @@
       public Object convert(Class type, Object value) {
   
           if (value == null) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException("No value specified");
  @@ -143,7 +151,7 @@
           try {
               return (new Short((String) value));
           } catch (Exception e) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException(e);
  
  
  
  1.2       +15 -7     jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/SqlDateConverter.java
  
  Index: SqlDateConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/SqlDateConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SqlDateConverter.java	18 Mar 2002 16:32:43 -0000	1.1
  +++ SqlDateConverter.java	11 Apr 2002 19:50:06 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/SqlDateConverter.java,v
1.1 2002/03/18 16:32:43 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/03/18 16:32:43 $
  + * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/SqlDateConverter.java,v
1.2 2002/04/11 19:50:06 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/11 19:50:06 $
    *
    * ====================================================================
    *
  @@ -75,7 +75,7 @@
    * error occurs.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2002/03/18 16:32:43 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/11 19:50:06 $
    * @since 1.3
    */
   
  @@ -91,7 +91,8 @@
        */
       public SqlDateConverter() {
   
  -        this(null);
  +        this.defaultValue = null;
  +        this.useDefault = false;
   
       }
   
  @@ -105,6 +106,7 @@
       public SqlDateConverter(Object defaultValue) {
   
           this.defaultValue = defaultValue;
  +        this.useDefault = true;
   
       }
   
  @@ -118,6 +120,12 @@
       private Object defaultValue = null;
   
   
  +    /**
  +     * Should we return the default value on conversion errors?
  +     */
  +    private boolean useDefault = true;
  +
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -134,7 +142,7 @@
       public Object convert(Class type, Object value) {
   
           if (value == null) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException("No value specified");
  @@ -144,7 +152,7 @@
           try {
               return (Date.valueOf((String) value));
           } catch (Exception e) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException(e);
  
  
  
  1.2       +15 -7     jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/SqlTimeConverter.java
  
  Index: SqlTimeConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/SqlTimeConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SqlTimeConverter.java	18 Mar 2002 16:32:43 -0000	1.1
  +++ SqlTimeConverter.java	11 Apr 2002 19:50:06 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/SqlTimeConverter.java,v
1.1 2002/03/18 16:32:43 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/03/18 16:32:43 $
  + * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/SqlTimeConverter.java,v
1.2 2002/04/11 19:50:06 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/11 19:50:06 $
    *
    * ====================================================================
    *
  @@ -75,7 +75,7 @@
    * error occurs.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2002/03/18 16:32:43 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/11 19:50:06 $
    * @since 1.3
    */
   
  @@ -91,7 +91,8 @@
        */
       public SqlTimeConverter() {
   
  -        this(null);
  +        this.defaultValue = null;
  +        this.useDefault = false;
   
       }
   
  @@ -105,6 +106,7 @@
       public SqlTimeConverter(Object defaultValue) {
   
           this.defaultValue = defaultValue;
  +        this.useDefault = true;
   
       }
   
  @@ -118,6 +120,12 @@
       private Object defaultValue = null;
   
   
  +    /**
  +     * Should we return the default value on conversion errors?
  +     */
  +    private boolean useDefault = true;
  +
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -134,7 +142,7 @@
       public Object convert(Class type, Object value) {
   
           if (value == null) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException("No value specified");
  @@ -144,7 +152,7 @@
           try {
               return (Time.valueOf((String) value));
           } catch (Exception e) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException(e);
  
  
  
  1.2       +15 -7     jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/SqlTimestampConverter.java
  
  Index: SqlTimestampConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/SqlTimestampConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SqlTimestampConverter.java	18 Mar 2002 16:32:43 -0000	1.1
  +++ SqlTimestampConverter.java	11 Apr 2002 19:50:06 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/SqlTimestampConverter.java,v
1.1 2002/03/18 16:32:43 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/03/18 16:32:43 $
  + * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/SqlTimestampConverter.java,v
1.2 2002/04/11 19:50:06 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/11 19:50:06 $
    *
    * ====================================================================
    *
  @@ -75,7 +75,7 @@
    * error occurs.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2002/03/18 16:32:43 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/11 19:50:06 $
    * @since 1.3
    */
   
  @@ -91,7 +91,8 @@
        */
       public SqlTimestampConverter() {
   
  -        this(null);
  +        this.defaultValue = null;
  +        this.useDefault = false;
   
       }
   
  @@ -105,6 +106,7 @@
       public SqlTimestampConverter(Object defaultValue) {
   
           this.defaultValue = defaultValue;
  +        this.useDefault = true;
   
       }
   
  @@ -118,6 +120,12 @@
       private Object defaultValue = null;
   
   
  +    /**
  +     * Should we return the default value on conversion errors?
  +     */
  +    private boolean useDefault = true;
  +
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -134,7 +142,7 @@
       public Object convert(Class type, Object value) {
   
           if (value == null) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException("No value specified");
  @@ -144,7 +152,7 @@
           try {
               return (Timestamp.valueOf((String) value));
           } catch (Exception e) {
  -            if (defaultValue != null) {
  +            if (useDefault) {
                   return (defaultValue);
               } else {
                   throw new ConversionException(e);
  
  
  

--
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