commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benedikt Ritter <brit...@apache.org>
Subject Re: svn commit: r1535154 - in /commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters: AbstractConverter.java BooleanConverter.java CharacterConverter.java
Date Thu, 24 Oct 2013 10:12:14 GMT
Hi Oliver

2013/10/23 <oheger@apache.org>

> Author: oheger
> Date: Wed Oct 23 20:17:12 2013
> New Revision: 1535154
>
> URL: http://svn.apache.org/r1535154
> Log:
> Extracted a method for creating a standard conversion exception.
>
> This exception is thrown if a conversion of a value to a desired target
> type
> is not possible. It is used by multiple converter sub classes.
>
> Modified:
>
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/AbstractConverter.java
>
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/BooleanConverter.java
>
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/CharacterConverter.java
>
> Modified:
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/AbstractConverter.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/AbstractConverter.java?rev=1535154&r1=1535153&r2=1535154&view=diff
>
> ==============================================================================
> ---
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/AbstractConverter.java
> (original)
> +++
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/AbstractConverter.java
> Wed Oct 23 20:17:12 2013
> @@ -488,4 +488,18 @@ public abstract class AbstractConverter
>          T result = (T) convert(getDefaultType(), value);
>          return result;
>      }
> +
> +    /**
> +     * Generates a standard conversion exception with a message
> indicating that
> +     * the passed in value cannot be converted to the desired target type.
> +     *
> +     * @param type the target type
> +     * @param value the value to be converted
> +     * @return a {@code ConversionException} with a standard message
> +     * @since 1.9
> +     */
> +    protected ConversionException conversionException(Class<?> type,
> Object value) {
> +        return new ConversionException("Can't convert value '" + value
> +                + "' to type " + type);
> +    }
>

Looks like this could be a static creation method on ConversionException
(or even a constructor?!)

Benedikt


>  }
>
> Modified:
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/BooleanConverter.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/BooleanConverter.java?rev=1535154&r1=1535153&r2=1535154&view=diff
>
> ==============================================================================
> ---
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/BooleanConverter.java
> (original)
> +++
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/BooleanConverter.java
> Wed Oct 23 20:17:12 2013
> @@ -224,7 +224,7 @@ public final class BooleanConverter exte
>              }
>          }
>
> -        throw new ConversionException("Can't convert value '" + value +
> "' to type " + type);
> +        throw conversionException(type, value);
>      }
>
>      /**
>
> Modified:
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/CharacterConverter.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/CharacterConverter.java?rev=1535154&r1=1535153&r2=1535154&view=diff
>
> ==============================================================================
> ---
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/CharacterConverter.java
> (original)
> +++
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/CharacterConverter.java
> Wed Oct 23 20:17:12 2013
> @@ -16,7 +16,6 @@
>   */
>  package org.apache.commons.beanutils.converters;
>
> -import org.apache.commons.beanutils.ConversionException;
>
>  /**
>   * {@link org.apache.commons.beanutils.Converter} implementaion that
> handles conversion
> @@ -89,8 +88,7 @@ public final class CharacterConverter ex
>              return type.cast(new Character(value.toString().charAt(0)));
>          }
>
> -        throw new ConversionException("Can't convert value '" + value
> -                + "' to type " + type);
> +        throw conversionException(type, value);
>      }
>
>  }
>
>
>


-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message