avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib ObjectToStringConverter.java StringToBigDecimalConverter.java StringToBigIntegerConverter.java StringToBooleanConverter.java StringToByteConverter.java StringToClassConverter.java StringToDateConverter.java StringToDoubleConverter.java StringToFloatConverter.java StringToIntegerConverter.java StringToLongConverter.java StringToShortConverter.java StringToTimeConverter.java StringToTimestampConverter.java StringToURLConverter.java
Date Tue, 16 Jul 2002 01:09:49 GMT
donaldp     2002/07/15 18:09:49

  Modified:    converter/src/java/org/apache/excalibur/converter
                        AbstractConverter.java
               converter/src/java/org/apache/excalibur/converter/lib
                        ObjectToStringConverter.java
                        StringToBigDecimalConverter.java
                        StringToBigIntegerConverter.java
                        StringToBooleanConverter.java
                        StringToByteConverter.java
                        StringToClassConverter.java
                        StringToDateConverter.java
                        StringToDoubleConverter.java
                        StringToFloatConverter.java
                        StringToIntegerConverter.java
                        StringToLongConverter.java
                        StringToShortConverter.java
                        StringToTimeConverter.java
                        StringToTimestampConverter.java
                        StringToURLConverter.java
  Log:
  Incorporate default value handling for converters.
  Essentially this allows converters to be instantiated
  with a default value which will be returned when otherwise
  a ConverterException woudl be raised.
  
  Revision  Changes    Path
  1.3       +33 -9     jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/AbstractConverter.java
  
  Index: AbstractConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/AbstractConverter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractConverter.java	16 Jul 2002 00:41:35 -0000	1.2
  +++ AbstractConverter.java	16 Jul 2002 01:09:49 -0000	1.3
  @@ -24,6 +24,7 @@
   
       private final Class m_source;
       private final Class m_destination;
  +    private final Object m_defaultValue;
   
       /**
        * Constructor for a converter between types source and destination
  @@ -31,10 +32,26 @@
        * @param source the source type
        * @param destination the destination type
        */
  -    public AbstractConverter( final Class source, final Class destination )
  +    protected AbstractConverter( final Class source, final Class destination )
  +    {
  +        this( source, destination, null );
  +    }
  +
  +    /**
  +     * Constructor for a converter between types source and destination
  +     * with a default value.
  +     *
  +     * @param source the source type
  +     * @param destination the destination type
  +     * @param defaultValue the default value
  +     */
  +    protected AbstractConverter( final Class source,
  +                                 final Class destination,
  +                                 final Object defaultValue )
       {
           m_source = source;
           m_destination = destination;
  +        m_defaultValue = defaultValue;
       }
   
       /**
  @@ -75,13 +92,20 @@
       protected final Object noConvert( final Object value, final Throwable throwable )
           throws ConverterException
       {
  -        final String message =
  -            REZ.getString( "no-convert.error",
  -                           m_source.getName(),
  -                           m_destination.getName(),
  -                           value,
  -                           throwable );
  -        throw new ConverterException( message );
  +        if( null != m_defaultValue )
  +        {
  +            return m_defaultValue;
  +        }
  +        else
  +        {
  +            final String message =
  +                REZ.getString( "no-convert.error",
  +                               m_source.getName(),
  +                               m_destination.getName(),
  +                               value,
  +                               throwable );
  +            throw new ConverterException( message );
  +        }
       }
   
       /**
  
  
  
  1.2       +15 -3     jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/ObjectToStringConverter.java
  
  Index: ObjectToStringConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/ObjectToStringConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ObjectToStringConverter.java	27 Apr 2002 05:23:01 -0000	1.1
  +++ ObjectToStringConverter.java	16 Jul 2002 01:09:49 -0000	1.2
  @@ -27,11 +27,23 @@
        */
       public ObjectToStringConverter()
       {
  -        super( Object.class, String.class );
  +        this( null );
       }
   
       /**
  -     * Converts a object to a string.
  +     * Construct the converter with a default value.
  +     * If the default value is non-null, it will be returned if unable
  +     * to convert object to correct type.
  +     *
  +     * @param defaultValue the default value
  +     */
  +    public ObjectToStringConverter( final String defaultValue )
  +    {
  +        super( Object.class, String.class, defaultValue );
  +    }
  +
  +    /**
  +     * Converts an {@link Object} to a {@link String}.
        *
        * @param original the original object to convert
        * @param context the context in which to convert object (unused)
  
  
  
  1.3       +15 -3     jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToBigDecimalConverter.java
  
  Index: StringToBigDecimalConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToBigDecimalConverter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StringToBigDecimalConverter.java	16 Jul 2002 00:41:35 -0000	1.2
  +++ StringToBigDecimalConverter.java	16 Jul 2002 01:09:49 -0000	1.3
  @@ -12,7 +12,7 @@
   import org.apache.excalibur.converter.ConverterException;
   
   /**
  - * String to {@link BigDecimal} converter.
  + * {@link String} to {@link BigDecimal} converter.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @ant.converter source="java.lang.String" destination="java.math.BigDecimal"
  @@ -25,11 +25,23 @@
        */
       public StringToBigDecimalConverter()
       {
  -        super( String.class, BigDecimal.class );
  +        this( null );
       }
   
       /**
  -     * Converts a string to a BigDecimal.
  +     * Construct the converter with a default value.
  +     * If the default value is non-null, it will be returned if unable
  +     * to convert object to correct type.
  +     *
  +     * @param defaultValue the default value
  +     */
  +    public StringToBigDecimalConverter( final BigDecimal defaultValue )
  +    {
  +        super( String.class, BigDecimal.class, defaultValue );
  +    }
  +
  +    /**
  +     * Converts a {@link String} to a {@link BigDecimal}.
        *
        * @param object the original object to convert
        * @param context the context in which to convert object (unused)
  
  
  
  1.3       +15 -3     jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToBigIntegerConverter.java
  
  Index: StringToBigIntegerConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToBigIntegerConverter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StringToBigIntegerConverter.java	16 Jul 2002 00:41:35 -0000	1.2
  +++ StringToBigIntegerConverter.java	16 Jul 2002 01:09:49 -0000	1.3
  @@ -12,7 +12,7 @@
   import org.apache.excalibur.converter.ConverterException;
   
   /**
  - * String to {@link BigInteger} converter.
  + * {@link String} to {@link BigInteger} converter.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @ant.converter source="java.lang.String" destination="java.math.BigInteger"
  @@ -25,11 +25,23 @@
        */
       public StringToBigIntegerConverter()
       {
  -        super( String.class, BigInteger.class );
  +        this( null );
       }
   
       /**
  -     * Converts a string to a BigInteger.
  +     * Construct the converter with a default value.
  +     * If the default value is non-null, it will be returned if unable
  +     * to convert object to correct type.
  +     *
  +     * @param defaultValue the default value
  +     */
  +    public StringToBigIntegerConverter( final BigInteger defaultValue )
  +    {
  +        super( String.class, BigInteger.class, defaultValue );
  +    }
  +
  +    /**
  +     * Converts a {@link String} to a {@link BigInteger}.
        *
        * @param object the original object to convert
        * @param context the context in which to convert object (unused)
  
  
  
  1.5       +16 -3     jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToBooleanConverter.java
  
  Index: StringToBooleanConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToBooleanConverter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StringToBooleanConverter.java	16 Jul 2002 00:41:35 -0000	1.4
  +++ StringToBooleanConverter.java	16 Jul 2002 01:09:49 -0000	1.5
  @@ -9,9 +9,10 @@
   
   import org.apache.excalibur.converter.AbstractConverter;
   import org.apache.excalibur.converter.ConverterException;
  +import java.math.BigInteger;
   
   /**
  - * String to boolean converter
  + * {@link String} to {@link Boolean} converter
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @ant.converter source="java.lang.String" destination="java.lang.Boolean"
  @@ -24,11 +25,23 @@
        */
       public StringToBooleanConverter()
       {
  -        super( String.class, Boolean.class );
  +        this( null );
       }
   
       /**
  -     * Converts a string to a boolean.
  +     * Construct the converter with a default value.
  +     * If the default value is non-null, it will be returned if unable
  +     * to convert object to correct type.
  +     *
  +     * @param defaultValue the default value
  +     */
  +    public StringToBooleanConverter( final Boolean defaultValue )
  +    {
  +        super( String.class, Boolean.class, defaultValue );
  +    }
  +
  +    /**
  +     * Converts a {@link String} to a {@link Boolean}.
        *
        * @param object the original object to convert
        * @param context the context in which to convert object (unused)
  
  
  
  1.4       +15 -3     jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToByteConverter.java
  
  Index: StringToByteConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToByteConverter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StringToByteConverter.java	16 Jul 2002 00:41:35 -0000	1.3
  +++ StringToByteConverter.java	16 Jul 2002 01:09:49 -0000	1.4
  @@ -11,7 +11,7 @@
   import org.apache.excalibur.converter.ConverterException;
   
   /**
  - * String to byte converter
  + * {@link String} to {@link Byte} converter
    *
    * <p>Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary
    * numbers begin with 0b, all other values are assumed to be decimal.</p>
  @@ -27,11 +27,23 @@
        */
       public StringToByteConverter()
       {
  -        super( String.class, Byte.class );
  +        this( null );
       }
   
       /**
  -     * Converts a string to a byte.
  +     * Construct the converter with a default value.
  +     * If the default value is non-null, it will be returned if unable
  +     * to convert object to correct type.
  +     *
  +     * @param defaultValue the default value
  +     */
  +    public StringToByteConverter( final Byte defaultValue )
  +    {
  +        super( String.class, Byte.class, defaultValue );
  +    }
  +
  +    /**
  +     * Converts a {@link String} to a {@link Byte}.
        *
        * @param object the original object to convert
        * @param context the context in which to convert object (unused)
  
  
  
  1.4       +15 -3     jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToClassConverter.java
  
  Index: StringToClassConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToClassConverter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StringToClassConverter.java	16 Jul 2002 00:41:35 -0000	1.3
  +++ StringToClassConverter.java	16 Jul 2002 01:09:49 -0000	1.4
  @@ -11,7 +11,7 @@
   import org.apache.excalibur.converter.ConverterException;
   
   /**
  - * String to class converter
  + * {@link String} to class converter
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @ant.converter source="java.lang.String" destination="java.lang.Class"
  @@ -24,11 +24,23 @@
        */
       public StringToClassConverter()
       {
  -        super( String.class, Class.class );
  +        this( null );
       }
   
       /**
  -     * Converts a string to a class.
  +     * Construct the converter with a default value.
  +     * If the default value is non-null, it will be returned if unable
  +     * to convert object to correct type.
  +     *
  +     * @param defaultValue the default value
  +     */
  +    public StringToClassConverter( final Class defaultValue )
  +    {
  +        super( String.class, Class.class, defaultValue );
  +    }
  +
  +    /**
  +     * Converts a {@link String} to a {@link Class}.
        *
        * @param object the original object to convert
        * @param context the context in which to convert object (unused)
  
  
  
  1.5       +15 -3     jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToDateConverter.java
  
  Index: StringToDateConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToDateConverter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StringToDateConverter.java	16 Jul 2002 00:41:35 -0000	1.4
  +++ StringToDateConverter.java	16 Jul 2002 01:09:49 -0000	1.5
  @@ -13,7 +13,7 @@
   import org.apache.excalibur.converter.ConverterException;
   
   /**
  - * String to date converter.
  + * {@link String} to date converter.
    *
    * <p>Parses a date according to the same rules as the Date.parse() method. In
    * particular it recognizes the IETF standard date syntax:</p>
  @@ -31,11 +31,23 @@
        */
       public StringToDateConverter()
       {
  -        super( String.class, Date.class );
  +        this( null );
       }
   
       /**
  -     * Converts a string to a date.
  +     * Construct the converter with a default value.
  +     * If the default value is non-null, it will be returned if unable
  +     * to convert object to correct type.
  +     *
  +     * @param defaultValue the default value
  +     */
  +    public StringToDateConverter( final Date defaultValue )
  +    {
  +        super( String.class, Date.class, defaultValue );
  +    }
  +
  +    /**
  +     * Converts a {@link String} to a {@link Date}.
        *
        * @param object the original object to convert
        * @param context the context in which to convert object (unused)
  
  
  
  1.4       +15 -3     jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToDoubleConverter.java
  
  Index: StringToDoubleConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToDoubleConverter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StringToDoubleConverter.java	16 Jul 2002 00:41:35 -0000	1.3
  +++ StringToDoubleConverter.java	16 Jul 2002 01:09:49 -0000	1.4
  @@ -11,7 +11,7 @@
   import org.apache.excalibur.converter.ConverterException;
   
   /**
  - * String to double converter
  + * {@link String} to {@link Double} converter
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @ant.converter source="java.lang.String" destination="java.lang.Double"
  @@ -24,11 +24,23 @@
        */
       public StringToDoubleConverter()
       {
  -        super( String.class, Double.class );
  +        this( null );
       }
   
       /**
  -     * Converts a string to a double.
  +     * Construct the converter with a default value.
  +     * If the default value is non-null, it will be returned if unable
  +     * to convert object to correct type.
  +     *
  +     * @param defaultValue the default value
  +     */
  +    public StringToDoubleConverter( final Double defaultValue )
  +    {
  +        super( String.class, Double.class, defaultValue );
  +    }
  +
  +    /**
  +     * Converts a {@link String} to a {@link Double}.
        *
        * @param object the original object to convert
        * @param context the context in which to convert object (unused)
  
  
  
  1.4       +16 -3     jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToFloatConverter.java
  
  Index: StringToFloatConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToFloatConverter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StringToFloatConverter.java	16 Jul 2002 00:41:35 -0000	1.3
  +++ StringToFloatConverter.java	16 Jul 2002 01:09:49 -0000	1.4
  @@ -9,9 +9,10 @@
   
   import org.apache.excalibur.converter.AbstractConverter;
   import org.apache.excalibur.converter.ConverterException;
  +import java.util.Date;
   
   /**
  - * String to float converter
  + * {@link String} to float converter
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @ant.converter source="java.lang.String" destination="java.lang.Float"
  @@ -24,11 +25,23 @@
        */
       public StringToFloatConverter()
       {
  -        super( String.class, Float.class );
  +        this( null );
       }
   
       /**
  -     * Converts a string to a float.
  +     * Construct the converter with a default value.
  +     * If the default value is non-null, it will be returned if unable
  +     * to convert object to correct type.
  +     *
  +     * @param defaultValue the default value
  +     */
  +    public StringToFloatConverter( final Float defaultValue )
  +    {
  +        super( String.class, Float.class, defaultValue );
  +    }
  +
  +    /**
  +     * Converts a {@link String} to a {@link Float}.
        *
        * @param object the original object to convert
        * @param context the context in which to convert object (unused)
  
  
  
  1.4       +15 -3     jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToIntegerConverter.java
  
  Index: StringToIntegerConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToIntegerConverter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StringToIntegerConverter.java	16 Jul 2002 00:41:35 -0000	1.3
  +++ StringToIntegerConverter.java	16 Jul 2002 01:09:49 -0000	1.4
  @@ -11,7 +11,7 @@
   import org.apache.excalibur.converter.ConverterException;
   
   /**
  - * String to integer converter.
  + * {@link String} to {@link Integer} converter.
    *
    * <p>Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary
    * numbers begin with 0b, all other values are assumed to be decimal.</p>
  @@ -27,11 +27,23 @@
        */
       public StringToIntegerConverter()
       {
  -        super( String.class, Integer.class );
  +        this( null );
       }
   
       /**
  -     * Converts a string to an Integer.
  +     * Construct the converter with a default value.
  +     * If the default value is non-null, it will be returned if unable
  +     * to convert object to correct type.
  +     *
  +     * @param defaultValue the default value
  +     */
  +    public StringToIntegerConverter( final Integer defaultValue )
  +    {
  +        super( String.class, Integer.class, defaultValue );
  +    }
  +
  +    /**
  +     * Converts a {@link String} to an {@link Integer}.
        *
        * @param object the original object to convert
        * @param context the context in which to convert object (unused)
  
  
  
  1.4       +15 -3     jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToLongConverter.java
  
  Index: StringToLongConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToLongConverter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StringToLongConverter.java	16 Jul 2002 00:41:35 -0000	1.3
  +++ StringToLongConverter.java	16 Jul 2002 01:09:49 -0000	1.4
  @@ -11,7 +11,7 @@
   import org.apache.excalibur.converter.ConverterException;
   
   /**
  - * String to long converter
  + * {@link String} to {@link Long} converter
    *
    * <p>Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary
    * numbers begin with 0b, all other values are assumed to be decimal.</p>
  @@ -27,11 +27,23 @@
        */
       public StringToLongConverter()
       {
  -        super( String.class, Long.class );
  +        this( null );
       }
   
       /**
  -     * Converts a string to a long.
  +     * Construct the converter with a default value.
  +     * If the default value is non-null, it will be returned if unable
  +     * to convert object to correct type.
  +     *
  +     * @param defaultValue the default value
  +     */
  +    public StringToLongConverter( final Long defaultValue )
  +    {
  +        super( String.class, Long.class, defaultValue );
  +    }
  +
  +    /**
  +     * Converts a {@link String} to a {@link Long}.
        *
        * @param object the original object to convert
        * @param context the context in which to convert object (unused)
  
  
  
  1.4       +15 -3     jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToShortConverter.java
  
  Index: StringToShortConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToShortConverter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StringToShortConverter.java	16 Jul 2002 00:41:35 -0000	1.3
  +++ StringToShortConverter.java	16 Jul 2002 01:09:49 -0000	1.4
  @@ -11,7 +11,7 @@
   import org.apache.excalibur.converter.ConverterException;
   
   /**
  - * String to short converter
  + * {@link String} to {@link Short} converter.
    *
    * <p>Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary
    * numbers begin with 0b, all other values are assumed to be decimal.</p>
  @@ -27,11 +27,23 @@
        */
       public StringToShortConverter()
       {
  -        super( String.class, Short.class );
  +        this( null );
       }
   
       /**
  -     * Converts a string to a short.
  +     * Construct the converter with a default value.
  +     * If the default value is non-null, it will be returned if unable
  +     * to convert object to correct type.
  +     *
  +     * @param defaultValue the default value
  +     */
  +    public StringToShortConverter( final Short defaultValue )
  +    {
  +        super( String.class, Short.class, defaultValue );
  +    }
  +
  +    /**
  +     * Converts a {@link String} to a {@link Short}.
        *
        * @param object the original object to convert
        * @param context the context in which to convert object (unused)
  
  
  
  1.3       +15 -3     jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToTimeConverter.java
  
  Index: StringToTimeConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToTimeConverter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StringToTimeConverter.java	16 Jul 2002 00:41:35 -0000	1.2
  +++ StringToTimeConverter.java	16 Jul 2002 01:09:49 -0000	1.3
  @@ -12,7 +12,7 @@
   import org.apache.excalibur.converter.ConverterException;
   
   /**
  - * String to {@link Time} converter.
  + * {@link String} to {@link Time} converter.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @ant.converter source="java.lang.String" destination="java.sql.Time"
  @@ -25,11 +25,23 @@
        */
       public StringToTimeConverter()
       {
  -        super( String.class, Time.class );
  +        this( null );
       }
   
       /**
  -     * Converts a string to a BigInteger.
  +     * Construct the converter with a default value.
  +     * If the default value is non-null, it will be returned if unable
  +     * to convert object to correct type.
  +     *
  +     * @param defaultValue the default value
  +     */
  +    public StringToTimeConverter( final Time defaultValue )
  +    {
  +        super( String.class, Time.class, defaultValue );
  +    }
  +
  +    /**
  +     * Converts a {@link String} to a {@link Time}.
        *
        * @param object the original object to convert
        * @param context the context in which to convert object (unused)
  
  
  
  1.3       +16 -6     jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToTimestampConverter.java
  
  Index: StringToTimestampConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToTimestampConverter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StringToTimestampConverter.java	16 Jul 2002 00:41:35 -0000	1.2
  +++ StringToTimestampConverter.java	16 Jul 2002 01:09:49 -0000	1.3
  @@ -7,14 +7,12 @@
    */
   package org.apache.excalibur.converter.lib;
   
  -import org.apache.avalon.excalibur.i18n.ResourceManager;
  -import org.apache.avalon.excalibur.i18n.Resources;
  +import java.sql.Timestamp;
   import org.apache.excalibur.converter.AbstractConverter;
   import org.apache.excalibur.converter.ConverterException;
  -import java.sql.Timestamp;
   
   /**
  - * String to {@link Timestamp} converter.
  + * {@link String} to {@link Timestamp} converter.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @ant.converter source="java.lang.String" destination="java.sql.Time"
  @@ -27,11 +25,23 @@
        */
       public StringToTimestampConverter()
       {
  -        super( String.class, Timestamp.class );
  +        this( null );
  +    }
  +
  +    /**
  +     * Construct the converter with a default value.
  +     * If the default value is non-null, it will be returned if unable
  +     * to convert object to correct type.
  +     *
  +     * @param defaultValue the default value
  +     */
  +    public StringToTimestampConverter( final Timestamp defaultValue )
  +    {
  +        super( String.class, Timestamp.class, defaultValue );
       }
   
       /**
  -     * Converts a string to a Timestamp.
  +     * Converts a {@link String} to a {@link Timestamp}.
        *
        * @param object the original object to convert
        * @param context the context in which to convert object (unused)
  
  
  
  1.4       +15 -3     jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToURLConverter.java
  
  Index: StringToURLConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToURLConverter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StringToURLConverter.java	16 Jul 2002 00:41:35 -0000	1.3
  +++ StringToURLConverter.java	16 Jul 2002 01:09:49 -0000	1.4
  @@ -13,7 +13,7 @@
   import org.apache.excalibur.converter.ConverterException;
   
   /**
  - * String to url converter
  + * {@link String} to {@link URL} converter
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @ant.converter source="java.lang.String" destination="java.net.URL"
  @@ -26,11 +26,23 @@
        */
       public StringToURLConverter()
       {
  -        super( String.class, URL.class );
  +        this( null );
       }
   
       /**
  -     * Converts a string to a url.
  +     * Construct the converter with a default value.
  +     * If the default value is non-null, it will be returned if unable
  +     * to convert object to correct type.
  +     *
  +     * @param defaultValue the default value
  +     */
  +    public StringToURLConverter( final URL defaultValue )
  +    {
  +        super( String.class, URL.class, defaultValue );
  +    }
  +
  +    /**
  +     * Converts a {@link String} to a {@link URL}.
        *
        * @param object the original object to convert
        * @param context the context in which to convert object (unused)
  
  
  

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


Mime
View raw message