You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ma...@apache.org on 2003/01/11 23:02:15 UTC

cvs commit: jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/locale BaseLocaleConverter.java LocaleBeanUtils.java LocaleConvertUtils.java LocaleConverter.java

martinc     2003/01/11 14:02:15

  Modified:    beanutils/src/java/org/apache/commons/beanutils/locale
                        BaseLocaleConverter.java LocaleBeanUtils.java
                        LocaleConvertUtils.java LocaleConverter.java
  Log:
  Fix line ends.
  
  PR: 15908
  Submitted by: Dirk Heydtmann
  
  Revision  Changes    Path
  1.2       +275 -275  jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/locale/BaseLocaleConverter.java
  
  Index: BaseLocaleConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/locale/BaseLocaleConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BaseLocaleConverter.java	3 Sep 2002 21:34:20 -0000	1.1
  +++ BaseLocaleConverter.java	11 Jan 2003 22:02:15 -0000	1.2
  @@ -1,275 +1,275 @@
  -/*
  - * $Header$
  - * $Revision$
  - * $Date$
  - *
  - * ====================================================================
  - *
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  - *
  - * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written
  - *    permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - *
  - */
  -
  -package org.apache.commons.beanutils.locale;
  -
  -import org.apache.commons.beanutils.ConversionException;
  -
  -import java.text.ParseException;
  -import java.util.Locale;
  -
  -
  -/**
  - * <p>The base class for all standart type locale-sensitive converters.
  - * It has {@link LocaleConverter} and {@link org.apache.commons.beanutils.Converter} implementations,
  - * that convert an incoming locale-sensitive Object into an object of correspond type,
  - * optionally using a default value or throwing a {@link ConversionException}
  - * if a conversion error occurs.</p>
  - *
  - * @author Yauheny Mikulski
  - */
  -
  -public abstract class BaseLocaleConverter implements LocaleConverter {
  -
  -    // ----------------------------------------------------- Instance Variables
  -
  -    /** The default value specified to our Constructor, if any. */
  -    private Object defaultValue = null;
  -
  -    /** Should we return the default value on conversion errors? */
  -    protected boolean useDefault = false;
  -
  -    /** The locale specified to our Constructor, by default - system locale. */
  -    protected Locale locale = Locale.getDefault();
  -
  -    /** The default pattern specified to our Constructor, if any. */
  -    protected String pattern = null;
  -
  -    /** The flag indicating whether the given pattern string is localized or not. */
  -    protected boolean locPattern = false;
  -
  -    // ----------------------------------------------------------- Constructors
  -
  -    /**
  -     * Create a {@link LocaleConverter} that will throw a {@link ConversionException}
  -     * if a conversion error occurs.
  -     * An unlocalized pattern is used for the convertion.
  -     *
  -     * @param locale        The locale
  -     * @param pattern       The convertion pattern
  -     */
  -    protected BaseLocaleConverter(Locale locale, String pattern) {
  -
  -        this(null, locale, pattern, false, false);
  -    }
  -
  -    /**
  -     * Create a {@link LocaleConverter} that will throw a {@link ConversionException}
  -     * if a conversion error occurs.
  -     *
  -     * @param locale        The locale
  -     * @param pattern       The convertion pattern
  -     * @param locPattern    Indicate whether the pattern is localized or not
  -     */
  -    protected BaseLocaleConverter(Locale locale, String pattern, boolean locPattern) {
  -
  -        this(null, locale, pattern, false, locPattern);
  -    }
  -
  -    /**
  -     * Create a {@link LocaleConverter} that will return the specified default value
  -     * if a conversion error occurs.
  -     * An unlocalized pattern is used for the convertion.
  -     *
  -     * @param defaultValue  The default value to be returned
  -     * @param locale        The locale
  -     * @param pattern       The convertion pattern
  -     */
  -    protected BaseLocaleConverter(Object defaultValue, Locale locale, String pattern) {
  -
  -        this(defaultValue, locale, pattern, false);
  -    }
  -
  -    /**
  -     * Create a {@link LocaleConverter} that will return the specified default value
  -     * if a conversion error occurs.
  -     *
  -     * @param defaultValue  The default value to be returned
  -     * @param locale        The locale
  -     * @param pattern       The convertion pattern
  -     * @param locPattern    Indicate whether the pattern is localized or not
  -     */
  -    protected BaseLocaleConverter(Object defaultValue, Locale locale, String pattern, boolean locPattern) {
  -
  -        this(defaultValue, locale, pattern, true, locPattern);
  -    }
  -
  -    /**
  -     * Create a {@link LocaleConverter} that will return the specified default value
  -     * or throw a {@link ConversionException} if a conversion error occurs.
  -     *
  -     * @param defaultValue  The default value to be returned
  -     * @param locale        The locale
  -     * @param pattern       The convertion pattern
  -     * @param useDefault    Indicate whether the default value is used or not
  -     * @param locPattern    Indicate whether the pattern is localized or not
  -     */
  -    private BaseLocaleConverter(Object defaultValue, Locale locale,
  -                                String pattern, boolean useDefault, boolean locPattern) {
  -
  -        if (useDefault) {
  -            this.defaultValue = defaultValue;
  -            this.useDefault = true;
  -        }
  -
  -        if (locale != null) {
  -            this.locale = locale;
  -        }
  -
  -        this.pattern = pattern;
  -        this.locPattern = locPattern;
  -    }
  -
  -    // --------------------------------------------------------- Methods
  -
  -    /**
  -     * Convert the specified locale-sensitive input object into an output object of the
  -     * specified type.
  -     *
  -     * @param value The input object to be converted
  -     * @param pattern The pattern is used for the convertion
  -     *
  -     * @exception ConversionException if conversion cannot be performed
  -     *  successfully
  -     */
  -
  -    abstract protected Object parse(Object value, String pattern) throws ParseException;
  -
  -
  -    /**
  -     * Convert the specified locale-sensitive input object into an output object.
  -     * The default pattern is used for the convertion.
  -     *
  -     * @param value The input object to be converted
  -     *
  -     * @exception ConversionException if conversion cannot be performed
  -     *  successfully
  -     */
  -    public Object convert(Object value) {
  -        return convert(value, null);
  -    }
  -
  -    /**
  -     * Convert the specified locale-sensitive input object into an output object.
  -     *
  -     * @param value The input object to be converted
  -     * @param pattern The pattern is used for the convertion
  -     *
  -     * @exception ConversionException if conversion cannot be performed
  -     *  successfully
  -     */
  -    public Object convert(Object value, String pattern) {
  -        return convert(null, value, pattern);
  -    }
  -
  -    /**
  -     * Convert the specified locale-sensitive input object into an output object of the
  -     * specified type. The default pattern is used for the convertion.
  -     *
  -     * @param type Data type to which this value should be converted
  -     * @param value The input object to be converted
  -     *
  -     * @exception ConversionException if conversion cannot be performed
  -     *  successfully
  -     */
  -    public Object convert(Class type, Object value) {
  -        return convert(type, value, null);
  -    }
  -
  -    /**
  -     * Convert the specified locale-sensitive input object into an output object of the
  -     * specified type.
  -     *
  -     * @param type Data type to which this value should be converted
  -     * @param value The input object to be converted
  -     * @param pattern The pattern is used for the convertion
  -     *
  -     * @exception ConversionException if conversion cannot be performed
  -     *  successfully
  -     */
  -    public Object convert(Class type, Object value, String pattern) {
  -        if (value == null) {
  -            if (useDefault) {
  -                return (defaultValue);
  -            }
  -            else {
  -                throw new ConversionException("No value specified");
  -            }
  -        }
  -
  -        try {
  -            if (pattern != null) {
  -                return parse(value, pattern);
  -            }
  -            else {
  -                return parse(value, this.pattern);
  -            }
  -        }
  -        catch (Exception e) {
  -            if (useDefault) {
  -                return (defaultValue);
  -            }
  -            else {
  -                throw new ConversionException(e);
  -            }
  -        }
  -    }
  -}
  +/*
  + * $Header$
  + * $Revision$
  + * $Date$
  + *
  + * ====================================================================
  + *
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Group.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + *
  + */
  +
  +package org.apache.commons.beanutils.locale;
  +
  +import org.apache.commons.beanutils.ConversionException;
  +
  +import java.text.ParseException;
  +import java.util.Locale;
  +
  +
  +/**
  + * <p>The base class for all standart type locale-sensitive converters.
  + * It has {@link LocaleConverter} and {@link org.apache.commons.beanutils.Converter} implementations,
  + * that convert an incoming locale-sensitive Object into an object of correspond type,
  + * optionally using a default value or throwing a {@link ConversionException}
  + * if a conversion error occurs.</p>
  + *
  + * @author Yauheny Mikulski
  + */
  +
  +public abstract class BaseLocaleConverter implements LocaleConverter {
  +
  +    // ----------------------------------------------------- Instance Variables
  +
  +    /** The default value specified to our Constructor, if any. */
  +    private Object defaultValue = null;
  +
  +    /** Should we return the default value on conversion errors? */
  +    protected boolean useDefault = false;
  +
  +    /** The locale specified to our Constructor, by default - system locale. */
  +    protected Locale locale = Locale.getDefault();
  +
  +    /** The default pattern specified to our Constructor, if any. */
  +    protected String pattern = null;
  +
  +    /** The flag indicating whether the given pattern string is localized or not. */
  +    protected boolean locPattern = false;
  +
  +    // ----------------------------------------------------------- Constructors
  +
  +    /**
  +     * Create a {@link LocaleConverter} that will throw a {@link ConversionException}
  +     * if a conversion error occurs.
  +     * An unlocalized pattern is used for the convertion.
  +     *
  +     * @param locale        The locale
  +     * @param pattern       The convertion pattern
  +     */
  +    protected BaseLocaleConverter(Locale locale, String pattern) {
  +
  +        this(null, locale, pattern, false, false);
  +    }
  +
  +    /**
  +     * Create a {@link LocaleConverter} that will throw a {@link ConversionException}
  +     * if a conversion error occurs.
  +     *
  +     * @param locale        The locale
  +     * @param pattern       The convertion pattern
  +     * @param locPattern    Indicate whether the pattern is localized or not
  +     */
  +    protected BaseLocaleConverter(Locale locale, String pattern, boolean locPattern) {
  +
  +        this(null, locale, pattern, false, locPattern);
  +    }
  +
  +    /**
  +     * Create a {@link LocaleConverter} that will return the specified default value
  +     * if a conversion error occurs.
  +     * An unlocalized pattern is used for the convertion.
  +     *
  +     * @param defaultValue  The default value to be returned
  +     * @param locale        The locale
  +     * @param pattern       The convertion pattern
  +     */
  +    protected BaseLocaleConverter(Object defaultValue, Locale locale, String pattern) {
  +
  +        this(defaultValue, locale, pattern, false);
  +    }
  +
  +    /**
  +     * Create a {@link LocaleConverter} that will return the specified default value
  +     * if a conversion error occurs.
  +     *
  +     * @param defaultValue  The default value to be returned
  +     * @param locale        The locale
  +     * @param pattern       The convertion pattern
  +     * @param locPattern    Indicate whether the pattern is localized or not
  +     */
  +    protected BaseLocaleConverter(Object defaultValue, Locale locale, String pattern, boolean locPattern) {
  +
  +        this(defaultValue, locale, pattern, true, locPattern);
  +    }
  +
  +    /**
  +     * Create a {@link LocaleConverter} that will return the specified default value
  +     * or throw a {@link ConversionException} if a conversion error occurs.
  +     *
  +     * @param defaultValue  The default value to be returned
  +     * @param locale        The locale
  +     * @param pattern       The convertion pattern
  +     * @param useDefault    Indicate whether the default value is used or not
  +     * @param locPattern    Indicate whether the pattern is localized or not
  +     */
  +    private BaseLocaleConverter(Object defaultValue, Locale locale,
  +                                String pattern, boolean useDefault, boolean locPattern) {
  +
  +        if (useDefault) {
  +            this.defaultValue = defaultValue;
  +            this.useDefault = true;
  +        }
  +
  +        if (locale != null) {
  +            this.locale = locale;
  +        }
  +
  +        this.pattern = pattern;
  +        this.locPattern = locPattern;
  +    }
  +
  +    // --------------------------------------------------------- Methods
  +
  +    /**
  +     * Convert the specified locale-sensitive input object into an output object of the
  +     * specified type.
  +     *
  +     * @param value The input object to be converted
  +     * @param pattern The pattern is used for the convertion
  +     *
  +     * @exception ConversionException if conversion cannot be performed
  +     *  successfully
  +     */
  +
  +    abstract protected Object parse(Object value, String pattern) throws ParseException;
  +
  +
  +    /**
  +     * Convert the specified locale-sensitive input object into an output object.
  +     * The default pattern is used for the convertion.
  +     *
  +     * @param value The input object to be converted
  +     *
  +     * @exception ConversionException if conversion cannot be performed
  +     *  successfully
  +     */
  +    public Object convert(Object value) {
  +        return convert(value, null);
  +    }
  +
  +    /**
  +     * Convert the specified locale-sensitive input object into an output object.
  +     *
  +     * @param value The input object to be converted
  +     * @param pattern The pattern is used for the convertion
  +     *
  +     * @exception ConversionException if conversion cannot be performed
  +     *  successfully
  +     */
  +    public Object convert(Object value, String pattern) {
  +        return convert(null, value, pattern);
  +    }
  +
  +    /**
  +     * Convert the specified locale-sensitive input object into an output object of the
  +     * specified type. The default pattern is used for the convertion.
  +     *
  +     * @param type Data type to which this value should be converted
  +     * @param value The input object to be converted
  +     *
  +     * @exception ConversionException if conversion cannot be performed
  +     *  successfully
  +     */
  +    public Object convert(Class type, Object value) {
  +        return convert(type, value, null);
  +    }
  +
  +    /**
  +     * Convert the specified locale-sensitive input object into an output object of the
  +     * specified type.
  +     *
  +     * @param type Data type to which this value should be converted
  +     * @param value The input object to be converted
  +     * @param pattern The pattern is used for the convertion
  +     *
  +     * @exception ConversionException if conversion cannot be performed
  +     *  successfully
  +     */
  +    public Object convert(Class type, Object value, String pattern) {
  +        if (value == null) {
  +            if (useDefault) {
  +                return (defaultValue);
  +            }
  +            else {
  +                throw new ConversionException("No value specified");
  +            }
  +        }
  +
  +        try {
  +            if (pattern != null) {
  +                return parse(value, pattern);
  +            }
  +            else {
  +                return parse(value, this.pattern);
  +            }
  +        }
  +        catch (Exception e) {
  +            if (useDefault) {
  +                return (defaultValue);
  +            }
  +            else {
  +                throw new ConversionException(e);
  +            }
  +        }
  +    }
  +}
  
  
  
  1.2       +889 -889  jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/locale/LocaleBeanUtils.java
  
  Index: LocaleBeanUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/locale/LocaleBeanUtils.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LocaleBeanUtils.java	3 Sep 2002 21:34:20 -0000	1.1
  +++ LocaleBeanUtils.java	11 Jan 2003 22:02:15 -0000	1.2
  @@ -1,889 +1,889 @@
  -/*
  - * $Header$
  - * $Revision$
  - * $Date$
  - *
  - * ====================================================================
  - *
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  - *
  - * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written
  - *    permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - *
  - */
  -
  -package org.apache.commons.beanutils.locale;
  -
  -
  -import org.apache.commons.beanutils.*;
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogFactory;
  -
  -import java.beans.IndexedPropertyDescriptor;
  -import java.beans.PropertyDescriptor;
  -import java.lang.reflect.InvocationTargetException;
  -import java.util.Locale;
  -
  -
  -/**
  - * Utility methods for populating JavaBeans properties
  - * via reflection in a locale-dependent manner.
  - *
  - * @author Craig R. McClanahan
  - * @author Ralph Schaer
  - * @author Chris Audley
  - * @author Rey Fran�ois
  - * @author Gregor Ra�man
  - * @author Yauheny Mikulski
  - */
  -
  -public class LocaleBeanUtils extends BeanUtils {
  -
  -
  -    // ----------------------------------------------------- Instance Variables
  -
  -    /** All logging goes through this logger */
  -    private static Log log = LogFactory.getLog(LocaleBeanUtils.class);
  -
  -    /**
  -     * getter for defaultLocale
  -     */
  -    public static Locale getDefaultLocale() {
  -
  -        return LocaleConvertUtils.getDefaultLocale();
  -    }
  -
  -
  -    /**
  -     * setter for defaultLocale
  -     */
  -    public static void setDefaultLocale(Locale locale) {
  -
  -        LocaleConvertUtils.setDefaultLocale(locale);
  -    }
  -
  -    /**
  -     * getter for applyLocalized
  -     * (Indicate whether the pattern is localized or not)
  -     */
  -    public static boolean getApplyLocalized() {
  -
  -        return LocaleConvertUtils.getApplyLocalized();
  -    }
  -
  -    /**
  -     * setter for applyLocalized
  -     * (Indicate whether the pattern is localized or not)
  -     */
  -    public static void setApplyLocalized(boolean newApplyLocalized) {
  -
  -        LocaleConvertUtils.setApplyLocalized(newApplyLocalized);
  -    }
  -
  -
  -    // --------------------------------------------------------- Public Methods
  -
  -    /**
  -     * Return the value of the specified locale-sensitive indexed property
  -     * of the specified bean, as a String. The zero-relative index of the
  -     * required value must be included (in square brackets) as a suffix to
  -     * the property name, or <code>IllegalArgumentException</code> will be
  -     * thrown.
  -     *
  -     * @param bean Bean whose property is to be extracted
  -     * @param name <code>propertyname[index]</code> of the property value
  -     *  to be extracted
  -     * @param pattern The convertion pattern
  -     *
  -     * @exception IllegalAccessException if the caller does not have
  -     *  access to the property accessor method
  -     * @exception InvocationTargetException if the property accessor method
  -     *  throws an exception
  -     * @exception NoSuchMethodException if an accessor method for this
  -     *  propety cannot be found
  -     */
  -    public static String getIndexedProperty(Object bean, String name, String pattern)
  -            throws IllegalAccessException, InvocationTargetException,
  -            NoSuchMethodException {
  -
  -        Object value = PropertyUtils.getIndexedProperty(bean, name);
  -        return LocaleConvertUtils.convert(value, pattern);
  -    }
  -
  -    /**
  -     * Return the value of the specified locale-sensitive indexed property
  -     * of the specified bean, as a String using the default convertion pattern of
  -     * the corresponding {@link LocaleConverter}. The zero-relative index
  -     * of the required value must be included (in square brackets) as a suffix
  -     * to the property name, or <code>IllegalArgumentException</code> will be thrown.
  -     *
  -     * @param bean Bean whose property is to be extracted
  -     * @param name <code>propertyname[index]</code> of the property value
  -     *  to be extracted
  -     *
  -     * @exception IllegalAccessException if the caller does not have
  -     *  access to the property accessor method
  -     * @exception InvocationTargetException if the property accessor method
  -     *  throws an exception
  -     * @exception NoSuchMethodException if an accessor method for this
  -     *  propety cannot be found
  -     */
  -    public static String getIndexedProperty(Object bean, String name)
  -            throws IllegalAccessException, InvocationTargetException,
  -            NoSuchMethodException {
  -
  -        return getIndexedProperty(bean, name, null);
  -    }
  -
  -    /**
  -     * Return the value of the specified locale-sensetive indexed property
  -     * of the specified bean, as a String using the specified convertion pattern.
  -     * The index is specified as a method parameter and
  -     * must *not* be included in the property name expression
  -     *
  -     * @param bean Bean whose property is to be extracted
  -     * @param name Simple property name of the property value to be extracted
  -     * @param index Index of the property value to be extracted
  -     * @param pattern The convertion pattern
  -     *
  -     * @exception IllegalAccessException if the caller does not have
  -     *  access to the property accessor method
  -     * @exception InvocationTargetException if the property accessor method
  -     *  throws an exception
  -     * @exception NoSuchMethodException if an accessor method for this
  -     *  propety cannot be found
  -     */
  -    public static String getIndexedProperty(Object bean,
  -                                            String name, int index, String pattern)
  -            throws IllegalAccessException, InvocationTargetException,
  -            NoSuchMethodException {
  -
  -        Object value = PropertyUtils.getIndexedProperty(bean, name, index);
  -        return LocaleConvertUtils.convert(value, pattern);
  -    }
  -
  -    /**
  -     * Return the value of the specified locale-sensetive indexed property
  -     * of the specified bean, as a String using the default convertion pattern of
  -     * the corresponding {@link LocaleConverter}.
  -     * The index is specified as a method parameter and
  -     * must *not* be included in the property name expression
  -     *
  -     * @param bean Bean whose property is to be extracted
  -     * @param name Simple property name of the property value to be extracted
  -     * @param index Index of the property value to be extracted
  -     *
  -     * @exception IllegalAccessException if the caller does not have
  -     *  access to the property accessor method
  -     * @exception InvocationTargetException if the property accessor method
  -     *  throws an exception
  -     * @exception NoSuchMethodException if an accessor method for this
  -     *  propety cannot be found
  -     */
  -    public static String getIndexedProperty(Object bean,
  -                                            String name, int index)
  -            throws IllegalAccessException, InvocationTargetException,
  -            NoSuchMethodException {
  -        return getIndexedProperty(bean, name, index, null);
  -    }
  -
  -    /**
  -     * Return the value of the specified simple locale-sensitive property
  -     * of the specified bean, converted to a String using the specified
  -     * convertion pattern.
  -     *
  -     * @param bean Bean whose property is to be extracted
  -     * @param name Name of the property to be extracted
  -     * @param pattern The convertion pattern
  -     *
  -     * @exception IllegalAccessException if the caller does not have
  -     *  access to the property accessor method
  -     * @exception InvocationTargetException if the property accessor method
  -     *  throws an exception
  -     * @exception NoSuchMethodException if an accessor method for this
  -     *  propety cannot be found
  -     */
  -    public static String getSimpleProperty(Object bean, String name, String pattern)
  -            throws IllegalAccessException, InvocationTargetException,
  -            NoSuchMethodException {
  -
  -        Object value = PropertyUtils.getSimpleProperty(bean, name);
  -        return LocaleConvertUtils.convert(value, pattern);
  -    }
  -
  -    /**
  -     * Return the value of the specified simple locale-sensitive property
  -     * of the specified bean, converted to a String using the default
  -     * convertion pattern of the corresponding {@link LocaleConverter}.
  -     *
  -     * @param bean Bean whose property is to be extracted
  -     * @param name Name of the property to be extracted
  -     *
  -     * @exception IllegalAccessException if the caller does not have
  -     *  access to the property accessor method
  -     * @exception InvocationTargetException if the property accessor method
  -     *  throws an exception
  -     * @exception NoSuchMethodException if an accessor method for this
  -     *  propety cannot be found
  -     */
  -    public static String getSimpleProperty(Object bean, String name)
  -            throws IllegalAccessException, InvocationTargetException,
  -            NoSuchMethodException {
  -
  -        return getSimpleProperty(bean, name, null);
  -    }
  -
  -    /**
  -     * Return the value of the specified mapped locale-sensitive property
  -     * of the specified bean, as a String using the specified convertion pattern.
  -     * The key is specified as a method parameter and must *not* be included in
  -     * the property name expression.
  -     *
  -     * @param bean Bean whose property is to be extracted
  -     * @param name Simple property name of the property value to be extracted
  -     * @param key Lookup key of the property value to be extracted
  -     * @param pattern The convertion pattern
  -     *
  -     * @exception IllegalAccessException if the caller does not have
  -     *  access to the property accessor method
  -     * @exception InvocationTargetException if the property accessor method
  -     *  throws an exception
  -     * @exception NoSuchMethodException if an accessor method for this
  -     *  propety cannot be found
  -     */
  -    public static String getMappedProperty(Object bean,
  -                                           String name, String key, String pattern)
  -            throws IllegalAccessException, InvocationTargetException,
  -            NoSuchMethodException {
  -
  -        Object value = PropertyUtils.getMappedProperty(bean, name, key);
  -        return LocaleConvertUtils.convert(value, pattern);
  -    }
  -
  -    /**
  -     * Return the value of the specified mapped locale-sensitive property
  -     * of the specified bean, as a String
  -     * The key is specified as a method parameter and must *not* be included
  -     * in the property name expression
  -     *
  -     * @param bean Bean whose property is to be extracted
  -     * @param name Simple property name of the property value to be extracted
  -     * @param key Lookup key of the property value to be extracted
  -     *
  -     * @exception IllegalAccessException if the caller does not have
  -     *  access to the property accessor method
  -     * @exception InvocationTargetException if the property accessor method
  -     *  throws an exception
  -     * @exception NoSuchMethodException if an accessor method for this
  -     *  propety cannot be found
  -     */
  -    public static String getMappedProperty(Object bean,
  -                                           String name, String key)
  -            throws IllegalAccessException, InvocationTargetException,
  -            NoSuchMethodException {
  -
  -        return getMappedProperty(bean, name, key, null);
  -    }
  -
  -
  -    /**
  -     * Return the value of the specified locale-sensitive mapped property
  -     * of the specified bean, as a String using the specified pattern.
  -     * The String-valued key of the required value
  -     * must be included (in parentheses) as a suffix to
  -     * the property name, or <code>IllegalArgumentException</code> will be
  -     * thrown.
  -     *
  -     * @param bean Bean whose property is to be extracted
  -     * @param name <code>propertyname(index)</code> of the property value
  -     *  to be extracted
  -     * @param pattern The convertion pattern
  -     *
  -     * @exception IllegalAccessException if the caller does not have
  -     *  access to the property accessor method
  -     * @exception InvocationTargetException if the property accessor method
  -     *  throws an exception
  -     * @exception NoSuchMethodException if an accessor method for this
  -     *  propety cannot be found
  -     */
  -    public static String getMappedPropertyLocale(Object bean, String name, String pattern)
  -            throws IllegalAccessException, InvocationTargetException,
  -            NoSuchMethodException {
  -
  -        Object value = PropertyUtils.getMappedProperty(bean, name);
  -        return LocaleConvertUtils.convert(value, pattern);
  -    }
  -
  -
  -    /**
  -     * Return the value of the specified locale-sensitive mapped property
  -     * of the specified bean, as a String using the default
  -     * convertion pattern of the corresponding {@link LocaleConverter}.
  -     * The String-valued key of the required value
  -     * must be included (in parentheses) as a suffix to
  -     * the property name, or <code>IllegalArgumentException</code> will be
  -     * thrown.
  -     *
  -     * @param bean Bean whose property is to be extracted
  -     * @param name <code>propertyname(index)</code> of the property value
  -     *  to be extracted
  -     *
  -     * @exception IllegalAccessException if the caller does not have
  -     *  access to the property accessor method
  -     * @exception InvocationTargetException if the property accessor method
  -     *  throws an exception
  -     * @exception NoSuchMethodException if an accessor method for this
  -     *  propety cannot be found
  -     */
  -    public static String getMappedProperty(Object bean, String name)
  -            throws IllegalAccessException, InvocationTargetException,
  -            NoSuchMethodException {
  -
  -        return getMappedPropertyLocale(bean, name, null);
  -    }
  -
  -    /**
  -     * Return the value of the (possibly nested) locale-sensitive property
  -     * of the specified name, for the specified bean,
  -     * as a String using the specified pattern.
  -     *
  -     * @param bean Bean whose property is to be extracted
  -     * @param name Possibly nested name of the property to be extracted
  -     * @param pattern The convertion pattern
  -     *
  -     * @exception IllegalAccessException if the caller does not have
  -     *  access to the property accessor method
  -     * @exception IllegalArgumentException if a nested reference to a
  -     *  property returns null
  -     * @exception InvocationTargetException if the property accessor method
  -     *  throws an exception
  -     * @exception NoSuchMethodException if an accessor method for this
  -     *  propety cannot be found
  -     */
  -    public static String getNestedProperty(Object bean, String name, String pattern)
  -            throws IllegalAccessException, InvocationTargetException,
  -            NoSuchMethodException {
  -
  -        Object value = PropertyUtils.getNestedProperty(bean, name);
  -        return LocaleConvertUtils.convert(value, pattern);
  -    }
  -
  -    /**
  -     * Return the value of the (possibly nested) locale-sensitive property
  -     * of the specified name, for the specified bean, as a String using the default
  -     * convertion pattern of the corresponding {@link LocaleConverter}.
  -     *
  -     * @param bean Bean whose property is to be extracted
  -     * @param name Possibly nested name of the property to be extracted
  -     *
  -     * @exception IllegalAccessException if the caller does not have
  -     *  access to the property accessor method
  -     * @exception IllegalArgumentException if a nested reference to a
  -     *  property returns null
  -     * @exception InvocationTargetException if the property accessor method
  -     *  throws an exception
  -     * @exception NoSuchMethodException if an accessor method for this
  -     *  propety cannot be found
  -     */
  -    public static String getNestedProperty(Object bean, String name)
  -            throws IllegalAccessException, InvocationTargetException,
  -            NoSuchMethodException {
  -
  -        return getNestedProperty(bean, name, null);
  -    }
  -
  -    /**
  -     * Return the value of the specified locale-sensitive property
  -     * of the specified bean, no matter which property reference
  -     * format is used, as a String using the specified convertion pattern.
  -     *
  -     * @param bean Bean whose property is to be extracted
  -     * @param name Possibly indexed and/or nested name of the property
  -     *  to be extracted
  -     * @param pattern The convertion pattern
  -     *
  -     * @exception IllegalAccessException if the caller does not have
  -     *  access to the property accessor method
  -     * @exception InvocationTargetException if the property accessor method
  -     *  throws an exception
  -     * @exception NoSuchMethodException if an accessor method for this
  -     *  propety cannot be found
  -     */
  -    public static String getProperty(Object bean, String name, String pattern)
  -            throws IllegalAccessException, InvocationTargetException,
  -            NoSuchMethodException {
  -
  -        return getNestedProperty(bean, name, pattern);
  -    }
  -
  -    /**
  -     * Return the value of the specified locale-sensitive property
  -     * of the specified bean, no matter which property reference
  -     * format is used, as a String using the default
  -     * convertion pattern of the corresponding {@link LocaleConverter}.
  -     *
  -     * @param bean Bean whose property is to be extracted
  -     * @param name Possibly indexed and/or nested name of the property
  -     *  to be extracted
  -     *
  -     * @exception IllegalAccessException if the caller does not have
  -     *  access to the property accessor method
  -     * @exception InvocationTargetException if the property accessor method
  -     *  throws an exception
  -     * @exception NoSuchMethodException if an accessor method for this
  -     *  propety cannot be found
  -     */
  -    public static String getProperty(Object bean, String name)
  -            throws IllegalAccessException, InvocationTargetException,
  -            NoSuchMethodException {
  -
  -        return getNestedProperty(bean, name);
  -    }
  -
  -    /**
  -     * Set the specified locale-sensitive property value, performing type
  -     * conversions as required to conform to the type of the destination property
  -     * using the default convertion pattern of the corresponding {@link LocaleConverter}.
  -     *
  -     * @param bean Bean on which setting is to be performed
  -     * @param name Property name (can be nested/indexed/mapped/combo)
  -     * @param value Value to be set
  -     *
  -     * @exception IllegalAccessException if the caller does not have
  -     *  access to the property accessor method
  -     * @exception InvocationTargetException if the property accessor method
  -     *  throws an exception
  -     */
  -    public static void setProperty(Object bean, String name, Object value)
  -            throws IllegalAccessException, InvocationTargetException {
  -
  -        setProperty(bean, name, value, null);
  -    }
  -
  -    /**
  -     * Set the specified locale-sensitive property value, performing type
  -     * conversions as required to conform to the type of the destination
  -     * property using the specified convertion pattern.
  -     *
  -     * @param bean Bean on which setting is to be performed
  -     * @param name Property name (can be nested/indexed/mapped/combo)
  -     * @param value Value to be set
  -     * @param pattern The convertion pattern
  -     *
  -     * @exception IllegalAccessException if the caller does not have
  -     *  access to the property accessor method
  -     * @exception InvocationTargetException if the property accessor method
  -     *  throws an exception
  -     */
  -    public static void setProperty(Object bean, String name, Object value, String pattern)
  -            throws IllegalAccessException, InvocationTargetException {
  -
  -        // Trace logging (if enabled)
  -        if (log.isTraceEnabled()) {
  -            StringBuffer sb = new StringBuffer("  setProperty(");
  -            sb.append(bean);
  -            sb.append(", ");
  -            sb.append(name);
  -            sb.append(", ");
  -            if (value == null) {
  -                sb.append("<NULL>");
  -            }
  -            else if (value instanceof String) {
  -                sb.append((String) value);
  -            }
  -            else if (value instanceof String[]) {
  -                String values[] = (String[]) value;
  -                sb.append('[');
  -                for (int i = 0; i < values.length; i++) {
  -                    if (i > 0) {
  -                        sb.append(',');
  -                    }
  -                    sb.append(values[i]);
  -                }
  -                sb.append(']');
  -            }
  -            else {
  -                sb.append(value.toString());
  -            }
  -            sb.append(')');
  -            log.trace(sb.toString());
  -        }
  -
  -        Descriptor propInfo = calculate(bean, name);
  -
  -        if (propInfo != null) {
  -            Class type = definePropertyType(propInfo.getTarget(), name, propInfo.getPropName());
  -
  -            if (type != null) {
  -
  -                Object newValue = convert(type, propInfo.getIndex(), value, pattern);
  -                invokeSetter(propInfo.getTarget(), propInfo.getPropName(),
  -                        propInfo.getKey(), propInfo.getIndex(), newValue);
  -            }
  -        }
  -    }
  -
  -    /**
  -     * Calculate the property type.
  -     *
  -     * @param target The bean
  -     * @param name The property name
  -     * @param propName The Simple name of target property
  -     *
  -     * @exception IllegalAccessException if the caller does not have
  -     *  access to the property accessor method
  -     * @exception InvocationTargetException if the property accessor method
  -     *  throws an exception
  -     */
  -    protected static Class definePropertyType(Object target, String name, String propName)
  -            throws IllegalAccessException, InvocationTargetException {
  -
  -        Class type = null;               // Java type of target property
  -
  -        if (target instanceof DynaBean) {
  -            DynaClass dynaClass = ((DynaBean) target).getDynaClass();
  -            DynaProperty dynaProperty = dynaClass.getDynaProperty(propName);
  -            if (dynaProperty == null) {
  -                return null; // Skip this property setter
  -            }
  -            type = dynaProperty.getType();
  -        }
  -        else {
  -            PropertyDescriptor descriptor = null;
  -            try {
  -                descriptor =
  -                        PropertyUtils.getPropertyDescriptor(target, name);
  -                if (descriptor == null) {
  -                    return null; // Skip this property setter
  -                }
  -            }
  -            catch (NoSuchMethodException e) {
  -                return null; // Skip this property setter
  -            }
  -            if (descriptor instanceof MappedPropertyDescriptor) {
  -                type = ((MappedPropertyDescriptor) descriptor).
  -                        getMappedPropertyType();
  -            }
  -            else if (descriptor instanceof IndexedPropertyDescriptor) {
  -                type = ((IndexedPropertyDescriptor) descriptor).
  -                        getIndexedPropertyType();
  -            }
  -            else {
  -                type = descriptor.getPropertyType();
  -            }
  -        }
  -        return type;
  -    }
  -
  -    /**
  -     * Convert the specified value to the required type using the
  -     * specified convertion pattern.
  -     *
  -     * @param type The Java type of target property
  -     * @param index The indexed subscript value (if any)
  -     * @param value The value to be converted
  -     * @param pattern The convertion pattern
  -     */
  -    protected static Object convert(Class type, int index, Object value, String pattern) {
  -
  -        Object newValue = null;
  -
  -        if (type.isArray() && (index < 0)) { // Scalar value into array
  -            if (value instanceof String) {
  -                String values[] = new String[1];
  -                values[0] = (String) value;
  -                newValue = LocaleConvertUtils.convert((String[]) values, type, pattern);
  -            }
  -            else if (value instanceof String[]) {
  -                newValue = LocaleConvertUtils.convert((String[]) value, type, pattern);
  -            }
  -            else {
  -                newValue = value;
  -            }
  -        }
  -        else if (type.isArray()) {         // Indexed value into array
  -            if (value instanceof String) {
  -                newValue = LocaleConvertUtils.convert((String) value,
  -                        type.getComponentType(), pattern);
  -            }
  -            else if (value instanceof String[]) {
  -                newValue = LocaleConvertUtils.convert(((String[]) value)[0],
  -                        type.getComponentType(), pattern);
  -            }
  -            else {
  -                newValue = value;
  -            }
  -        }
  -        else {                             // Value into scalar
  -            if (value instanceof String) {
  -                newValue = LocaleConvertUtils.convert((String) value, type, pattern);
  -            }
  -            else if (value instanceof String[]) {
  -                newValue = LocaleConvertUtils.convert(((String[]) value)[0],
  -                        type, pattern);
  -            }
  -            else {
  -                newValue = value;
  -            }
  -        }
  -        return newValue;
  -    }
  -
  -    /**
  -     *  Convert the specified value to the required type.
  -     *
  -     * @param type The Java type of target property
  -     * @param index The indexed subscript value (if any)
  -     * @param value The value to be converted
  -     */
  -    protected static Object convert(Class type, int index, Object value) {
  -
  -        Object newValue = null;
  -
  -        if (type.isArray() && (index < 0)) { // Scalar value into array
  -            if (value instanceof String) {
  -                String values[] = new String[1];
  -                values[0] = (String) value;
  -                newValue = ConvertUtils.convert((String[]) values, type);
  -            }
  -            else if (value instanceof String[]) {
  -                newValue = ConvertUtils.convert((String[]) value, type);
  -            }
  -            else {
  -                newValue = value;
  -            }
  -        }
  -        else if (type.isArray()) {         // Indexed value into array
  -            if (value instanceof String) {
  -                newValue = ConvertUtils.convert((String) value,
  -                        type.getComponentType());
  -            }
  -            else if (value instanceof String[]) {
  -                newValue = ConvertUtils.convert(((String[]) value)[0],
  -                        type.getComponentType());
  -            }
  -            else {
  -                newValue = value;
  -            }
  -        }
  -        else {                             // Value into scalar
  -            if (value instanceof String) {
  -                newValue = ConvertUtils.convert((String) value, type);
  -            }
  -            else if (value instanceof String[]) {
  -                newValue = ConvertUtils.convert(((String[]) value)[0],
  -                        type);
  -            }
  -            else {
  -                newValue = value;
  -            }
  -        }
  -        return newValue;
  -    }
  -
  -    /**
  -     * Invoke the setter method.
  -     *
  -     * @param target The bean
  -     * @param propName The Simple name of target property
  -     * @param key The Mapped key value (if any)
  -     * @param index The indexed subscript value (if any)
  -     * @param newValue The value to be set
  -     *
  -     * @exception IllegalAccessException if the caller does not have
  -     *  access to the property accessor method
  -     * @exception InvocationTargetException if the property accessor method
  -     *  throws an exception
  -     */
  -    protected static void invokeSetter(Object target, String propName, String key, int index, Object newValue)
  -            throws IllegalAccessException, InvocationTargetException {
  -
  -        try {
  -            if (index >= 0) {
  -                PropertyUtils.setIndexedProperty(target, propName,
  -                        index, newValue);
  -            }
  -            else if (key != null) {
  -                PropertyUtils.setMappedProperty(target, propName,
  -                        key, newValue);
  -            }
  -            else {
  -                PropertyUtils.setProperty(target, propName, newValue);
  -            }
  -        }
  -        catch (NoSuchMethodException e) {
  -            throw new InvocationTargetException
  -                    (e, "Cannot set " + propName);
  -        }
  -    }
  -
  -    /**
  -     * Resolve any nested expression to get the actual target bean.
  -     *
  -     * @param bean The bean
  -     * @param name The property name
  -     *
  -     * @exception IllegalAccessException if the caller does not have
  -     *  access to the property accessor method
  -     * @exception InvocationTargetException if the property accessor method
  -     *  throws an exception
  -     */
  -    protected static Descriptor calculate(Object bean, String name)
  -            throws IllegalAccessException, InvocationTargetException {
  -
  -        String propName = null;          // Simple name of target property
  -        int index = -1;                  // Indexed subscript value (if any)
  -        String key = null;               // Mapped key value (if any)
  -
  -        Object target = bean;
  -        int delim = name.lastIndexOf(PropertyUtils.NESTED_DELIM);
  -        if (delim >= 0) {
  -            try {
  -                target =
  -                        PropertyUtils.getProperty(bean, name.substring(0, delim));
  -            }
  -            catch (NoSuchMethodException e) {
  -                return null; // Skip this property setter
  -            }
  -            name = name.substring(delim + 1);
  -            if (log.isTraceEnabled()) {
  -                log.trace("    Target bean = " + target);
  -                log.trace("    Target name = " + name);
  -            }
  -        }
  -
  -        // Calculate the property name, index, and key values
  -        propName = name;
  -        int i = propName.indexOf(PropertyUtils.INDEXED_DELIM);
  -        if (i >= 0) {
  -            int k = propName.indexOf(PropertyUtils.INDEXED_DELIM2);
  -            try {
  -                index =
  -                        Integer.parseInt(propName.substring(i + 1, k));
  -            }
  -            catch (NumberFormatException e) {
  -                ;
  -            }
  -            propName = propName.substring(0, i);
  -        }
  -        int j = propName.indexOf(PropertyUtils.MAPPED_DELIM);
  -        if (j >= 0) {
  -            int k = propName.indexOf(PropertyUtils.MAPPED_DELIM2);
  -            try {
  -                key = propName.substring(j + 1, k);
  -            }
  -            catch (IndexOutOfBoundsException e) {
  -                ;
  -            }
  -            propName = propName.substring(0, j);
  -        }
  -        return new Descriptor(target, name, propName, key, index);
  -    }
  -
  -    protected static class Descriptor {
  -
  -        private int index = -1;    // Indexed subscript value (if any)
  -        private String name;
  -        private String propName;   // Simple name of target property
  -        private String key;        // Mapped key value (if any)
  -        private Object target;
  -
  -        public Descriptor(Object target, String name, String propName, String key, int index) {
  -
  -            setTarget(target);
  -            setName(name);
  -            setPropName(propName);
  -            setKey(key);
  -            setIndex(index);
  -        }
  -
  -        public Object getTarget() {
  -            return target;
  -        }
  -
  -        public void setTarget(Object target) {
  -            this.target = target;
  -        }
  -
  -        public String getKey() {
  -            return key;
  -        }
  -
  -        public void setKey(String key) {
  -            this.key = key;
  -        }
  -
  -        public int getIndex() {
  -            return index;
  -        }
  -
  -        public void setIndex(int index) {
  -            this.index = index;
  -        }
  -
  -        public String getName() {
  -            return name;
  -        }
  -
  -        public void setName(String name) {
  -            this.name = name;
  -        }
  -
  -        public String getPropName() {
  -            return propName;
  -        }
  -
  -        public void setPropName(String propName) {
  -            this.propName = propName;
  -        }
  -    }
  -}
  -
  -
  +/*
  + * $Header$
  + * $Revision$
  + * $Date$
  + *
  + * ====================================================================
  + *
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Group.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + *
  + */
  +
  +package org.apache.commons.beanutils.locale;
  +
  +
  +import org.apache.commons.beanutils.*;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
  +
  +import java.beans.IndexedPropertyDescriptor;
  +import java.beans.PropertyDescriptor;
  +import java.lang.reflect.InvocationTargetException;
  +import java.util.Locale;
  +
  +
  +/**
  + * Utility methods for populating JavaBeans properties
  + * via reflection in a locale-dependent manner.
  + *
  + * @author Craig R. McClanahan
  + * @author Ralph Schaer
  + * @author Chris Audley
  + * @author Rey Fran�ois
  + * @author Gregor Ra�man
  + * @author Yauheny Mikulski
  + */
  +
  +public class LocaleBeanUtils extends BeanUtils {
  +
  +
  +    // ----------------------------------------------------- Instance Variables
  +
  +    /** All logging goes through this logger */
  +    private static Log log = LogFactory.getLog(LocaleBeanUtils.class);
  +
  +    /**
  +     * getter for defaultLocale
  +     */
  +    public static Locale getDefaultLocale() {
  +
  +        return LocaleConvertUtils.getDefaultLocale();
  +    }
  +
  +
  +    /**
  +     * setter for defaultLocale
  +     */
  +    public static void setDefaultLocale(Locale locale) {
  +
  +        LocaleConvertUtils.setDefaultLocale(locale);
  +    }
  +
  +    /**
  +     * getter for applyLocalized
  +     * (Indicate whether the pattern is localized or not)
  +     */
  +    public static boolean getApplyLocalized() {
  +
  +        return LocaleConvertUtils.getApplyLocalized();
  +    }
  +
  +    /**
  +     * setter for applyLocalized
  +     * (Indicate whether the pattern is localized or not)
  +     */
  +    public static void setApplyLocalized(boolean newApplyLocalized) {
  +
  +        LocaleConvertUtils.setApplyLocalized(newApplyLocalized);
  +    }
  +
  +
  +    // --------------------------------------------------------- Public Methods
  +
  +    /**
  +     * Return the value of the specified locale-sensitive indexed property
  +     * of the specified bean, as a String. The zero-relative index of the
  +     * required value must be included (in square brackets) as a suffix to
  +     * the property name, or <code>IllegalArgumentException</code> will be
  +     * thrown.
  +     *
  +     * @param bean Bean whose property is to be extracted
  +     * @param name <code>propertyname[index]</code> of the property value
  +     *  to be extracted
  +     * @param pattern The convertion pattern
  +     *
  +     * @exception IllegalAccessException if the caller does not have
  +     *  access to the property accessor method
  +     * @exception InvocationTargetException if the property accessor method
  +     *  throws an exception
  +     * @exception NoSuchMethodException if an accessor method for this
  +     *  propety cannot be found
  +     */
  +    public static String getIndexedProperty(Object bean, String name, String pattern)
  +            throws IllegalAccessException, InvocationTargetException,
  +            NoSuchMethodException {
  +
  +        Object value = PropertyUtils.getIndexedProperty(bean, name);
  +        return LocaleConvertUtils.convert(value, pattern);
  +    }
  +
  +    /**
  +     * Return the value of the specified locale-sensitive indexed property
  +     * of the specified bean, as a String using the default convertion pattern of
  +     * the corresponding {@link LocaleConverter}. The zero-relative index
  +     * of the required value must be included (in square brackets) as a suffix
  +     * to the property name, or <code>IllegalArgumentException</code> will be thrown.
  +     *
  +     * @param bean Bean whose property is to be extracted
  +     * @param name <code>propertyname[index]</code> of the property value
  +     *  to be extracted
  +     *
  +     * @exception IllegalAccessException if the caller does not have
  +     *  access to the property accessor method
  +     * @exception InvocationTargetException if the property accessor method
  +     *  throws an exception
  +     * @exception NoSuchMethodException if an accessor method for this
  +     *  propety cannot be found
  +     */
  +    public static String getIndexedProperty(Object bean, String name)
  +            throws IllegalAccessException, InvocationTargetException,
  +            NoSuchMethodException {
  +
  +        return getIndexedProperty(bean, name, null);
  +    }
  +
  +    /**
  +     * Return the value of the specified locale-sensetive indexed property
  +     * of the specified bean, as a String using the specified convertion pattern.
  +     * The index is specified as a method parameter and
  +     * must *not* be included in the property name expression
  +     *
  +     * @param bean Bean whose property is to be extracted
  +     * @param name Simple property name of the property value to be extracted
  +     * @param index Index of the property value to be extracted
  +     * @param pattern The convertion pattern
  +     *
  +     * @exception IllegalAccessException if the caller does not have
  +     *  access to the property accessor method
  +     * @exception InvocationTargetException if the property accessor method
  +     *  throws an exception
  +     * @exception NoSuchMethodException if an accessor method for this
  +     *  propety cannot be found
  +     */
  +    public static String getIndexedProperty(Object bean,
  +                                            String name, int index, String pattern)
  +            throws IllegalAccessException, InvocationTargetException,
  +            NoSuchMethodException {
  +
  +        Object value = PropertyUtils.getIndexedProperty(bean, name, index);
  +        return LocaleConvertUtils.convert(value, pattern);
  +    }
  +
  +    /**
  +     * Return the value of the specified locale-sensetive indexed property
  +     * of the specified bean, as a String using the default convertion pattern of
  +     * the corresponding {@link LocaleConverter}.
  +     * The index is specified as a method parameter and
  +     * must *not* be included in the property name expression
  +     *
  +     * @param bean Bean whose property is to be extracted
  +     * @param name Simple property name of the property value to be extracted
  +     * @param index Index of the property value to be extracted
  +     *
  +     * @exception IllegalAccessException if the caller does not have
  +     *  access to the property accessor method
  +     * @exception InvocationTargetException if the property accessor method
  +     *  throws an exception
  +     * @exception NoSuchMethodException if an accessor method for this
  +     *  propety cannot be found
  +     */
  +    public static String getIndexedProperty(Object bean,
  +                                            String name, int index)
  +            throws IllegalAccessException, InvocationTargetException,
  +            NoSuchMethodException {
  +        return getIndexedProperty(bean, name, index, null);
  +    }
  +
  +    /**
  +     * Return the value of the specified simple locale-sensitive property
  +     * of the specified bean, converted to a String using the specified
  +     * convertion pattern.
  +     *
  +     * @param bean Bean whose property is to be extracted
  +     * @param name Name of the property to be extracted
  +     * @param pattern The convertion pattern
  +     *
  +     * @exception IllegalAccessException if the caller does not have
  +     *  access to the property accessor method
  +     * @exception InvocationTargetException if the property accessor method
  +     *  throws an exception
  +     * @exception NoSuchMethodException if an accessor method for this
  +     *  propety cannot be found
  +     */
  +    public static String getSimpleProperty(Object bean, String name, String pattern)
  +            throws IllegalAccessException, InvocationTargetException,
  +            NoSuchMethodException {
  +
  +        Object value = PropertyUtils.getSimpleProperty(bean, name);
  +        return LocaleConvertUtils.convert(value, pattern);
  +    }
  +
  +    /**
  +     * Return the value of the specified simple locale-sensitive property
  +     * of the specified bean, converted to a String using the default
  +     * convertion pattern of the corresponding {@link LocaleConverter}.
  +     *
  +     * @param bean Bean whose property is to be extracted
  +     * @param name Name of the property to be extracted
  +     *
  +     * @exception IllegalAccessException if the caller does not have
  +     *  access to the property accessor method
  +     * @exception InvocationTargetException if the property accessor method
  +     *  throws an exception
  +     * @exception NoSuchMethodException if an accessor method for this
  +     *  propety cannot be found
  +     */
  +    public static String getSimpleProperty(Object bean, String name)
  +            throws IllegalAccessException, InvocationTargetException,
  +            NoSuchMethodException {
  +
  +        return getSimpleProperty(bean, name, null);
  +    }
  +
  +    /**
  +     * Return the value of the specified mapped locale-sensitive property
  +     * of the specified bean, as a String using the specified convertion pattern.
  +     * The key is specified as a method parameter and must *not* be included in
  +     * the property name expression.
  +     *
  +     * @param bean Bean whose property is to be extracted
  +     * @param name Simple property name of the property value to be extracted
  +     * @param key Lookup key of the property value to be extracted
  +     * @param pattern The convertion pattern
  +     *
  +     * @exception IllegalAccessException if the caller does not have
  +     *  access to the property accessor method
  +     * @exception InvocationTargetException if the property accessor method
  +     *  throws an exception
  +     * @exception NoSuchMethodException if an accessor method for this
  +     *  propety cannot be found
  +     */
  +    public static String getMappedProperty(Object bean,
  +                                           String name, String key, String pattern)
  +            throws IllegalAccessException, InvocationTargetException,
  +            NoSuchMethodException {
  +
  +        Object value = PropertyUtils.getMappedProperty(bean, name, key);
  +        return LocaleConvertUtils.convert(value, pattern);
  +    }
  +
  +    /**
  +     * Return the value of the specified mapped locale-sensitive property
  +     * of the specified bean, as a String
  +     * The key is specified as a method parameter and must *not* be included
  +     * in the property name expression
  +     *
  +     * @param bean Bean whose property is to be extracted
  +     * @param name Simple property name of the property value to be extracted
  +     * @param key Lookup key of the property value to be extracted
  +     *
  +     * @exception IllegalAccessException if the caller does not have
  +     *  access to the property accessor method
  +     * @exception InvocationTargetException if the property accessor method
  +     *  throws an exception
  +     * @exception NoSuchMethodException if an accessor method for this
  +     *  propety cannot be found
  +     */
  +    public static String getMappedProperty(Object bean,
  +                                           String name, String key)
  +            throws IllegalAccessException, InvocationTargetException,
  +            NoSuchMethodException {
  +
  +        return getMappedProperty(bean, name, key, null);
  +    }
  +
  +
  +    /**
  +     * Return the value of the specified locale-sensitive mapped property
  +     * of the specified bean, as a String using the specified pattern.
  +     * The String-valued key of the required value
  +     * must be included (in parentheses) as a suffix to
  +     * the property name, or <code>IllegalArgumentException</code> will be
  +     * thrown.
  +     *
  +     * @param bean Bean whose property is to be extracted
  +     * @param name <code>propertyname(index)</code> of the property value
  +     *  to be extracted
  +     * @param pattern The convertion pattern
  +     *
  +     * @exception IllegalAccessException if the caller does not have
  +     *  access to the property accessor method
  +     * @exception InvocationTargetException if the property accessor method
  +     *  throws an exception
  +     * @exception NoSuchMethodException if an accessor method for this
  +     *  propety cannot be found
  +     */
  +    public static String getMappedPropertyLocale(Object bean, String name, String pattern)
  +            throws IllegalAccessException, InvocationTargetException,
  +            NoSuchMethodException {
  +
  +        Object value = PropertyUtils.getMappedProperty(bean, name);
  +        return LocaleConvertUtils.convert(value, pattern);
  +    }
  +
  +
  +    /**
  +     * Return the value of the specified locale-sensitive mapped property
  +     * of the specified bean, as a String using the default
  +     * convertion pattern of the corresponding {@link LocaleConverter}.
  +     * The String-valued key of the required value
  +     * must be included (in parentheses) as a suffix to
  +     * the property name, or <code>IllegalArgumentException</code> will be
  +     * thrown.
  +     *
  +     * @param bean Bean whose property is to be extracted
  +     * @param name <code>propertyname(index)</code> of the property value
  +     *  to be extracted
  +     *
  +     * @exception IllegalAccessException if the caller does not have
  +     *  access to the property accessor method
  +     * @exception InvocationTargetException if the property accessor method
  +     *  throws an exception
  +     * @exception NoSuchMethodException if an accessor method for this
  +     *  propety cannot be found
  +     */
  +    public static String getMappedProperty(Object bean, String name)
  +            throws IllegalAccessException, InvocationTargetException,
  +            NoSuchMethodException {
  +
  +        return getMappedPropertyLocale(bean, name, null);
  +    }
  +
  +    /**
  +     * Return the value of the (possibly nested) locale-sensitive property
  +     * of the specified name, for the specified bean,
  +     * as a String using the specified pattern.
  +     *
  +     * @param bean Bean whose property is to be extracted
  +     * @param name Possibly nested name of the property to be extracted
  +     * @param pattern The convertion pattern
  +     *
  +     * @exception IllegalAccessException if the caller does not have
  +     *  access to the property accessor method
  +     * @exception IllegalArgumentException if a nested reference to a
  +     *  property returns null
  +     * @exception InvocationTargetException if the property accessor method
  +     *  throws an exception
  +     * @exception NoSuchMethodException if an accessor method for this
  +     *  propety cannot be found
  +     */
  +    public static String getNestedProperty(Object bean, String name, String pattern)
  +            throws IllegalAccessException, InvocationTargetException,
  +            NoSuchMethodException {
  +
  +        Object value = PropertyUtils.getNestedProperty(bean, name);
  +        return LocaleConvertUtils.convert(value, pattern);
  +    }
  +
  +    /**
  +     * Return the value of the (possibly nested) locale-sensitive property
  +     * of the specified name, for the specified bean, as a String using the default
  +     * convertion pattern of the corresponding {@link LocaleConverter}.
  +     *
  +     * @param bean Bean whose property is to be extracted
  +     * @param name Possibly nested name of the property to be extracted
  +     *
  +     * @exception IllegalAccessException if the caller does not have
  +     *  access to the property accessor method
  +     * @exception IllegalArgumentException if a nested reference to a
  +     *  property returns null
  +     * @exception InvocationTargetException if the property accessor method
  +     *  throws an exception
  +     * @exception NoSuchMethodException if an accessor method for this
  +     *  propety cannot be found
  +     */
  +    public static String getNestedProperty(Object bean, String name)
  +            throws IllegalAccessException, InvocationTargetException,
  +            NoSuchMethodException {
  +
  +        return getNestedProperty(bean, name, null);
  +    }
  +
  +    /**
  +     * Return the value of the specified locale-sensitive property
  +     * of the specified bean, no matter which property reference
  +     * format is used, as a String using the specified convertion pattern.
  +     *
  +     * @param bean Bean whose property is to be extracted
  +     * @param name Possibly indexed and/or nested name of the property
  +     *  to be extracted
  +     * @param pattern The convertion pattern
  +     *
  +     * @exception IllegalAccessException if the caller does not have
  +     *  access to the property accessor method
  +     * @exception InvocationTargetException if the property accessor method
  +     *  throws an exception
  +     * @exception NoSuchMethodException if an accessor method for this
  +     *  propety cannot be found
  +     */
  +    public static String getProperty(Object bean, String name, String pattern)
  +            throws IllegalAccessException, InvocationTargetException,
  +            NoSuchMethodException {
  +
  +        return getNestedProperty(bean, name, pattern);
  +    }
  +
  +    /**
  +     * Return the value of the specified locale-sensitive property
  +     * of the specified bean, no matter which property reference
  +     * format is used, as a String using the default
  +     * convertion pattern of the corresponding {@link LocaleConverter}.
  +     *
  +     * @param bean Bean whose property is to be extracted
  +     * @param name Possibly indexed and/or nested name of the property
  +     *  to be extracted
  +     *
  +     * @exception IllegalAccessException if the caller does not have
  +     *  access to the property accessor method
  +     * @exception InvocationTargetException if the property accessor method
  +     *  throws an exception
  +     * @exception NoSuchMethodException if an accessor method for this
  +     *  propety cannot be found
  +     */
  +    public static String getProperty(Object bean, String name)
  +            throws IllegalAccessException, InvocationTargetException,
  +            NoSuchMethodException {
  +
  +        return getNestedProperty(bean, name);
  +    }
  +
  +    /**
  +     * Set the specified locale-sensitive property value, performing type
  +     * conversions as required to conform to the type of the destination property
  +     * using the default convertion pattern of the corresponding {@link LocaleConverter}.
  +     *
  +     * @param bean Bean on which setting is to be performed
  +     * @param name Property name (can be nested/indexed/mapped/combo)
  +     * @param value Value to be set
  +     *
  +     * @exception IllegalAccessException if the caller does not have
  +     *  access to the property accessor method
  +     * @exception InvocationTargetException if the property accessor method
  +     *  throws an exception
  +     */
  +    public static void setProperty(Object bean, String name, Object value)
  +            throws IllegalAccessException, InvocationTargetException {
  +
  +        setProperty(bean, name, value, null);
  +    }
  +
  +    /**
  +     * Set the specified locale-sensitive property value, performing type
  +     * conversions as required to conform to the type of the destination
  +     * property using the specified convertion pattern.
  +     *
  +     * @param bean Bean on which setting is to be performed
  +     * @param name Property name (can be nested/indexed/mapped/combo)
  +     * @param value Value to be set
  +     * @param pattern The convertion pattern
  +     *
  +     * @exception IllegalAccessException if the caller does not have
  +     *  access to the property accessor method
  +     * @exception InvocationTargetException if the property accessor method
  +     *  throws an exception
  +     */
  +    public static void setProperty(Object bean, String name, Object value, String pattern)
  +            throws IllegalAccessException, InvocationTargetException {
  +
  +        // Trace logging (if enabled)
  +        if (log.isTraceEnabled()) {
  +            StringBuffer sb = new StringBuffer("  setProperty(");
  +            sb.append(bean);
  +            sb.append(", ");
  +            sb.append(name);
  +            sb.append(", ");
  +            if (value == null) {
  +                sb.append("<NULL>");
  +            }
  +            else if (value instanceof String) {
  +                sb.append((String) value);
  +            }
  +            else if (value instanceof String[]) {
  +                String values[] = (String[]) value;
  +                sb.append('[');
  +                for (int i = 0; i < values.length; i++) {
  +                    if (i > 0) {
  +                        sb.append(',');
  +                    }
  +                    sb.append(values[i]);
  +                }
  +                sb.append(']');
  +            }
  +            else {
  +                sb.append(value.toString());
  +            }
  +            sb.append(')');
  +            log.trace(sb.toString());
  +        }
  +
  +        Descriptor propInfo = calculate(bean, name);
  +
  +        if (propInfo != null) {
  +            Class type = definePropertyType(propInfo.getTarget(), name, propInfo.getPropName());
  +
  +            if (type != null) {
  +
  +                Object newValue = convert(type, propInfo.getIndex(), value, pattern);
  +                invokeSetter(propInfo.getTarget(), propInfo.getPropName(),
  +                        propInfo.getKey(), propInfo.getIndex(), newValue);
  +            }
  +        }
  +    }
  +
  +    /**
  +     * Calculate the property type.
  +     *
  +     * @param target The bean
  +     * @param name The property name
  +     * @param propName The Simple name of target property
  +     *
  +     * @exception IllegalAccessException if the caller does not have
  +     *  access to the property accessor method
  +     * @exception InvocationTargetException if the property accessor method
  +     *  throws an exception
  +     */
  +    protected static Class definePropertyType(Object target, String name, String propName)
  +            throws IllegalAccessException, InvocationTargetException {
  +
  +        Class type = null;               // Java type of target property
  +
  +        if (target instanceof DynaBean) {
  +            DynaClass dynaClass = ((DynaBean) target).getDynaClass();
  +            DynaProperty dynaProperty = dynaClass.getDynaProperty(propName);
  +            if (dynaProperty == null) {
  +                return null; // Skip this property setter
  +            }
  +            type = dynaProperty.getType();
  +        }
  +        else {
  +            PropertyDescriptor descriptor = null;
  +            try {
  +                descriptor =
  +                        PropertyUtils.getPropertyDescriptor(target, name);
  +                if (descriptor == null) {
  +                    return null; // Skip this property setter
  +                }
  +            }
  +            catch (NoSuchMethodException e) {
  +                return null; // Skip this property setter
  +            }
  +            if (descriptor instanceof MappedPropertyDescriptor) {
  +                type = ((MappedPropertyDescriptor) descriptor).
  +                        getMappedPropertyType();
  +            }
  +            else if (descriptor instanceof IndexedPropertyDescriptor) {
  +                type = ((IndexedPropertyDescriptor) descriptor).
  +                        getIndexedPropertyType();
  +            }
  +            else {
  +                type = descriptor.getPropertyType();
  +            }
  +        }
  +        return type;
  +    }
  +
  +    /**
  +     * Convert the specified value to the required type using the
  +     * specified convertion pattern.
  +     *
  +     * @param type The Java type of target property
  +     * @param index The indexed subscript value (if any)
  +     * @param value The value to be converted
  +     * @param pattern The convertion pattern
  +     */
  +    protected static Object convert(Class type, int index, Object value, String pattern) {
  +
  +        Object newValue = null;
  +
  +        if (type.isArray() && (index < 0)) { // Scalar value into array
  +            if (value instanceof String) {
  +                String values[] = new String[1];
  +                values[0] = (String) value;
  +                newValue = LocaleConvertUtils.convert((String[]) values, type, pattern);
  +            }
  +            else if (value instanceof String[]) {
  +                newValue = LocaleConvertUtils.convert((String[]) value, type, pattern);
  +            }
  +            else {
  +                newValue = value;
  +            }
  +        }
  +        else if (type.isArray()) {         // Indexed value into array
  +            if (value instanceof String) {
  +                newValue = LocaleConvertUtils.convert((String) value,
  +                        type.getComponentType(), pattern);
  +            }
  +            else if (value instanceof String[]) {
  +                newValue = LocaleConvertUtils.convert(((String[]) value)[0],
  +                        type.getComponentType(), pattern);
  +            }
  +            else {
  +                newValue = value;
  +            }
  +        }
  +        else {                             // Value into scalar
  +            if (value instanceof String) {
  +                newValue = LocaleConvertUtils.convert((String) value, type, pattern);
  +            }
  +            else if (value instanceof String[]) {
  +                newValue = LocaleConvertUtils.convert(((String[]) value)[0],
  +                        type, pattern);
  +            }
  +            else {
  +                newValue = value;
  +            }
  +        }
  +        return newValue;
  +    }
  +
  +    /**
  +     *  Convert the specified value to the required type.
  +     *
  +     * @param type The Java type of target property
  +     * @param index The indexed subscript value (if any)
  +     * @param value The value to be converted
  +     */
  +    protected static Object convert(Class type, int index, Object value) {
  +
  +        Object newValue = null;
  +
  +        if (type.isArray() && (index < 0)) { // Scalar value into array
  +            if (value instanceof String) {
  +                String values[] = new String[1];
  +                values[0] = (String) value;
  +                newValue = ConvertUtils.convert((String[]) values, type);
  +            }
  +            else if (value instanceof String[]) {
  +                newValue = ConvertUtils.convert((String[]) value, type);
  +            }
  +            else {
  +                newValue = value;
  +            }
  +        }
  +        else if (type.isArray()) {         // Indexed value into array
  +            if (value instanceof String) {
  +                newValue = ConvertUtils.convert((String) value,
  +                        type.getComponentType());
  +            }
  +            else if (value instanceof String[]) {
  +                newValue = ConvertUtils.convert(((String[]) value)[0],
  +                        type.getComponentType());
  +            }
  +            else {
  +                newValue = value;
  +            }
  +        }
  +        else {                             // Value into scalar
  +            if (value instanceof String) {
  +                newValue = ConvertUtils.convert((String) value, type);
  +            }
  +            else if (value instanceof String[]) {
  +                newValue = ConvertUtils.convert(((String[]) value)[0],
  +                        type);
  +            }
  +            else {
  +                newValue = value;
  +            }
  +        }
  +        return newValue;
  +    }
  +
  +    /**
  +     * Invoke the setter method.
  +     *
  +     * @param target The bean
  +     * @param propName The Simple name of target property
  +     * @param key The Mapped key value (if any)
  +     * @param index The indexed subscript value (if any)
  +     * @param newValue The value to be set
  +     *
  +     * @exception IllegalAccessException if the caller does not have
  +     *  access to the property accessor method
  +     * @exception InvocationTargetException if the property accessor method
  +     *  throws an exception
  +     */
  +    protected static void invokeSetter(Object target, String propName, String key, int index, Object newValue)
  +            throws IllegalAccessException, InvocationTargetException {
  +
  +        try {
  +            if (index >= 0) {
  +                PropertyUtils.setIndexedProperty(target, propName,
  +                        index, newValue);
  +            }
  +            else if (key != null) {
  +                PropertyUtils.setMappedProperty(target, propName,
  +                        key, newValue);
  +            }
  +            else {
  +                PropertyUtils.setProperty(target, propName, newValue);
  +            }
  +        }
  +        catch (NoSuchMethodException e) {
  +            throw new InvocationTargetException
  +                    (e, "Cannot set " + propName);
  +        }
  +    }
  +
  +    /**
  +     * Resolve any nested expression to get the actual target bean.
  +     *
  +     * @param bean The bean
  +     * @param name The property name
  +     *
  +     * @exception IllegalAccessException if the caller does not have
  +     *  access to the property accessor method
  +     * @exception InvocationTargetException if the property accessor method
  +     *  throws an exception
  +     */
  +    protected static Descriptor calculate(Object bean, String name)
  +            throws IllegalAccessException, InvocationTargetException {
  +
  +        String propName = null;          // Simple name of target property
  +        int index = -1;                  // Indexed subscript value (if any)
  +        String key = null;               // Mapped key value (if any)
  +
  +        Object target = bean;
  +        int delim = name.lastIndexOf(PropertyUtils.NESTED_DELIM);
  +        if (delim >= 0) {
  +            try {
  +                target =
  +                        PropertyUtils.getProperty(bean, name.substring(0, delim));
  +            }
  +            catch (NoSuchMethodException e) {
  +                return null; // Skip this property setter
  +            }
  +            name = name.substring(delim + 1);
  +            if (log.isTraceEnabled()) {
  +                log.trace("    Target bean = " + target);
  +                log.trace("    Target name = " + name);
  +            }
  +        }
  +
  +        // Calculate the property name, index, and key values
  +        propName = name;
  +        int i = propName.indexOf(PropertyUtils.INDEXED_DELIM);
  +        if (i >= 0) {
  +            int k = propName.indexOf(PropertyUtils.INDEXED_DELIM2);
  +            try {
  +                index =
  +                        Integer.parseInt(propName.substring(i + 1, k));
  +            }
  +            catch (NumberFormatException e) {
  +                ;
  +            }
  +            propName = propName.substring(0, i);
  +        }
  +        int j = propName.indexOf(PropertyUtils.MAPPED_DELIM);
  +        if (j >= 0) {
  +            int k = propName.indexOf(PropertyUtils.MAPPED_DELIM2);
  +            try {
  +                key = propName.substring(j + 1, k);
  +            }
  +            catch (IndexOutOfBoundsException e) {
  +                ;
  +            }
  +            propName = propName.substring(0, j);
  +        }
  +        return new Descriptor(target, name, propName, key, index);
  +    }
  +
  +    protected static class Descriptor {
  +
  +        private int index = -1;    // Indexed subscript value (if any)
  +        private String name;
  +        private String propName;   // Simple name of target property
  +        private String key;        // Mapped key value (if any)
  +        private Object target;
  +
  +        public Descriptor(Object target, String name, String propName, String key, int index) {
  +
  +            setTarget(target);
  +            setName(name);
  +            setPropName(propName);
  +            setKey(key);
  +            setIndex(index);
  +        }
  +
  +        public Object getTarget() {
  +            return target;
  +        }
  +
  +        public void setTarget(Object target) {
  +            this.target = target;
  +        }
  +
  +        public String getKey() {
  +            return key;
  +        }
  +
  +        public void setKey(String key) {
  +            this.key = key;
  +        }
  +
  +        public int getIndex() {
  +            return index;
  +        }
  +
  +        public void setIndex(int index) {
  +            this.index = index;
  +        }
  +
  +        public String getName() {
  +            return name;
  +        }
  +
  +        public void setName(String name) {
  +            this.name = name;
  +        }
  +
  +        public String getPropName() {
  +            return propName;
  +        }
  +
  +        public void setPropName(String propName) {
  +            this.propName = propName;
  +        }
  +    }
  +}
  +
  +
  
  
  
  1.3       +460 -460  jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/locale/LocaleConvertUtils.java
  
  Index: LocaleConvertUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/locale/LocaleConvertUtils.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LocaleConvertUtils.java	7 Dec 2002 23:34:41 -0000	1.2
  +++ LocaleConvertUtils.java	11 Jan 2003 22:02:15 -0000	1.3
  @@ -1,460 +1,460 @@
  -/*
  - * $Header$
  - * $Revision$
  - * $Date$
  - *
  - * ====================================================================
  - *
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  - *
  - * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written
  - *    permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - *
  - */
  -
  -package org.apache.commons.beanutils.locale;
  -
  -import org.apache.commons.beanutils.locale.converters.*;
  -import org.apache.commons.collections.FastHashMap;
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogFactory;
  -
  -import java.lang.reflect.Array;
  -import java.math.BigDecimal;
  -import java.math.BigInteger;
  -import java.sql.Date;
  -import java.sql.Time;
  -import java.sql.Timestamp;
  -import java.util.Locale;
  -
  -/**
  - * <p>Utility methods for converting locale-sensitive String scalar values to objects of the
  - * specified Class, String arrays to arrays of the specified Class and
  - * object to locale-sensitive String scalar value.
  - *
  - * The actual {@link LocaleConverter} instance to be used
  - * can be registered for each possible destination Class. Unless you override them, standard
  - * {@link LocaleConverter} instances are provided for all of the following
  - * destination Classes:</p>
  - * <ul>
  - * <li>java.lang.BigDecimal</li>
  - * <li>java.lang.BigInteger</li>
  - * <li>byte and java.lang.Byte</li>
  - * <li>double and java.lang.Double</li>
  - * <li>float and java.lang.Float</li>
  - * <li>int and java.lang.Integer</li>
  - * <li>long and java.lang.Long</li>
  - * <li>short and java.lang.Short</li>
  - * <li>java.lang.String</li>
  - * <li>java.sql.Date</li>
  - * <li>java.sql.Time</li>
  - * <li>java.sql.Timestamp</li>
  - * </ul>
  - *
  - * <p>For backwards compatibility, the standard locale converters
  - * for primitive types (and the corresponding wrapper classes).
  - *
  - * If you prefer to have another {@link LocaleConverter}
  - * thrown instead, replace the standard {@link LocaleConverter} instances
  - * with ones created with the one of the appropriate constructors.
  - *
  - * It's important that {@link LocaleConverter} should be registered for
  - * the specified locale and Class (or primitive type).
  - *
  - * @author Yauheny Mikulski
  - */
  -public class LocaleConvertUtils {
  -
  -    // ----------------------------------------------------- Instance Variables
  -
  -    /** The locale - default for convertion. */
  -    private static Locale defaultLocale = Locale.getDefault();
  -
  -    /**
  -     * getter for defaultLocale
  -     */
  -    public static Locale getDefaultLocale() {
  -
  -        return defaultLocale;
  -    }
  -
  -    /**
  -     * setter for defaultLocale
  -     */
  -    public static void setDefaultLocale(Locale locale) {
  -
  -        if (locale == null) {
  -            defaultLocale = Locale.getDefault();
  -        }
  -        else {
  -            defaultLocale = locale;
  -        }
  -    }
  -
  -    /** Indicate whether the pattern is localized or not */
  -    private static boolean applyLocalized = false;
  -
  -    /**
  -     * getter for applyLocalized
  -     */
  -    public static boolean getApplyLocalized() {
  -        return applyLocalized;
  -    }
  -
  -    /**
  -     * setter for applyLocalized
  -     */
  -    public static void setApplyLocalized(boolean newApplyLocalized) {
  -        applyLocalized = newApplyLocalized;
  -    }
  -
  -    /** The <code>Log</code> instance for this class. */
  -    private static Log log = LogFactory.getLog(LocaleConvertUtils.class);
  -
  -    /** Every entry of the mapConverters is:
  -     *  key = locale
  -     *  value = FastHashMap of converters for the certain locale.
  -     */
  -    private static FastHashMap mapConverters = new FastHashMap();
  -
  -    /**
  -     * This code makes the state by default (deregisters all converters for all locales)
  -     *  and then registers default locale converters.
  -     */
  -    static {
  -        deregister();
  -    }
  -
  -    // --------------------------------------------------------- Methods
  -
  -    /**
  -     * Convert the specified locale-sensitive value into a String.
  -     *
  -     * @param value The Value to be converted
  -     *
  -     * @exception ConversionException if thrown by an underlying Converter
  -     */
  -    public static String convert(Object value) {
  -        return convert(value, defaultLocale, null);
  -    }
  -
  -    /**
  -     * Convert the specified locale-sensitive value into a String
  -     * using the convertion pattern.
  -     *
  -     * @param value The Value to be converted
  -     * @param pattern       The convertion pattern
  -     *
  -     * @exception ConversionException if thrown by an underlying Converter
  -     */
  -    public static String convert(Object value, String pattern) {
  -        return convert(value, defaultLocale, pattern);
  -    }
  -
  -    /**
  -     * Convert the specified locale-sensitive value into a String
  -     * using the paticular convertion pattern.
  -     *
  -     * @param value The Value to be converted
  -     * @param locale The locale
  -     * @param pattern The convertion pattern
  -     *
  -     * @exception ConversionException if thrown by an underlying Converter
  -     */
  -    public static String convert(Object value, Locale locale, String pattern) {
  -
  -        LocaleConverter converter = lookup(String.class, locale);
  -
  -        return (String) converter.convert(String.class, value, pattern);
  -    }
  -
  -    /**
  -     * Convert the specified value to an object of the specified class (if
  -     * possible).  Otherwise, return a String representation of the value.
  -     *
  -     * @param value The String scalar value to be converted
  -     * @param clazz The Data type to which this value should be converted.
  -     *
  -     * @exception ConversionException if thrown by an underlying Converter
  -     */
  -    public static Object convert(String value, Class clazz) {
  -
  -        return convert(value, clazz, defaultLocale, null);
  -    }
  -
  -    /**
  -     * Convert the specified value to an object of the specified class (if
  -     * possible) using the convertion pattern. Otherwise, return a String
  -     * representation of the value.
  -     *
  -     * @param value The String scalar value to be converted
  -     * @param clazz The Data type to which this value should be converted.
  -     * @param pattern The convertion pattern
  -     *
  -     * @exception ConversionException if thrown by an underlying Converter
  -     */
  -    public static Object convert(String value, Class clazz, String pattern) {
  -
  -        return convert(value, clazz, defaultLocale, pattern);
  -    }
  -
  -    /**
  -     * Convert the specified value to an object of the specified class (if
  -     * possible) using the convertion pattern. Otherwise, return a String
  -     * representation of the value.
  -     *
  -     * @param value The String scalar value to be converted
  -     * @param clazz The Data type to which this value should be converted.
  -     * @param locale The locale
  -     * @param pattern The convertion pattern
  -     *
  -     * @exception ConversionException if thrown by an underlying Converter
  -     */
  -    public static Object convert(String value, Class clazz, Locale locale, String pattern) {
  -
  -        if (log.isDebugEnabled()) {
  -            log.debug("Convert string " + value + " to class " +
  -                    clazz.getName() + " using " + locale.toString() +
  -                    " locale and " + pattern + " pattern");
  -        }
  -
  -        LocaleConverter converter = lookup(clazz, locale);
  -
  -        if (converter == null) {
  -            converter = (LocaleConverter) lookup(String.class, locale);
  -        }
  -        if (log.isTraceEnabled()) {
  -            log.trace("  Using converter " + converter);
  -        }
  -
  -        return (converter.convert(clazz, value, pattern));
  -    }
  -
  -    /**
  -     * Convert an array of specified values to an array of objects of the
  -     * specified class (if possible) using the convertion pattern.
  -     *
  -     * @param values Value to be converted (may be null)
  -     * @param clazz Java array or element class to be converted to
  -     * @param pattern The convertion pattern
  -     *
  -     * @exception ConversionException if thrown by an underlying Converter
  -     */
  -    public static Object convert(String values[], Class clazz, String pattern) {
  -
  -        return convert(values, clazz, getDefaultLocale(), pattern);
  -    }
  -
  -    /**
  -     * Convert an array of specified values to an array of objects of the
  -     * specified class (if possible) using the convertion pattern.
  -     *
  -     * @param values Value to be converted (may be null)
  -     * @param clazz Java array or element class to be converted to
  -     * @param locale The locale
  -     * @param pattern The convertion pattern
  -     *
  -     * @exception ConversionException if thrown by an underlying Converter
  -     */
  -    public static Object convert(String values[], Class clazz, Locale locale, String pattern) {
  -
  -        Class type = clazz;
  -        if (clazz.isArray()) {
  -            type = clazz.getComponentType();
  -        }
  -        if (log.isDebugEnabled()) {
  -            log.debug("Convert String[" + values.length + "] to class " +
  -                    type.getName() + "[] using " + locale.toString() +
  -                    " locale and " + pattern + " pattern");
  -        }
  -
  -        Object array = Array.newInstance(type, values.length);
  -        for (int i = 0; i < values.length; i++) {
  -            Array.set(array, i, convert(values[i], type, locale, pattern));
  -        }
  -
  -        return (array);
  -    }
  -
  -    /**
  -     * Register a custom {@link LocaleConverter} for the specified destination
  -     * <code>Class</code>, replacing any previously registered converter.
  -     *
  -     * @param converter The LocaleConverter to be registered
  -     * @param clazz The Destination class for conversions performed by this
  -     *  Converter
  -     * @param locale The locale
  -     */
  -    public static void register(LocaleConverter converter, Class clazz, Locale locale) {
  -
  -        lookup(locale).put(clazz, converter);
  -    }
  -
  -    /**
  -     * Remove any registered {@link LocaleConverter}.
  -     */
  -    public static void deregister() {
  -
  -        FastHashMap defaultConverter = lookup(defaultLocale);
  -
  -        mapConverters.setFast(false);
  -
  -        mapConverters.clear();
  -        mapConverters.put(defaultLocale, defaultConverter);
  -
  -        mapConverters.setFast(true);
  -    }
  -
  -
  -    /**
  -     * Remove any registered {@link LocaleConverter} for the specified locale
  -     *
  -     * @param locale The locale
  -     */
  -    public static void deregister(Locale locale) {
  -
  -        mapConverters.remove(locale);
  -    }
  -
  -
  -    /**
  -     * Remove any registered {@link LocaleConverter} for the specified locale and Class.
  -     *
  -     * @param clazz Class for which to remove a registered Converter
  -     * @param locale The locale
  -     */
  -    public static void deregister(Class clazz, Locale locale) {
  -
  -        lookup(locale).remove(clazz);
  -    }
  -
  -    /**
  -     * Look up and return any registered {@link LocaleConverter} for the specified
  -     * destination class and locale; if there is no registered Converter, return
  -     * <code>null</code>.
  -     *
  -     * @param clazz Class for which to return a registered Converter
  -     * @param locale The Locale
  -     */
  -    public static LocaleConverter lookup(Class clazz, Locale locale) {
  -
  -        return (LocaleConverter) lookup(locale).get(clazz);
  -    }
  -
  -    /**
  -     * Look up and return any registered FastHashMap instance for the specified locale;
  -     * if there is no registered one, return <code>null</code>.
  -     *
  -     * @param locale The Locale
  -     * @return The FastHashMap instance contains the all {@link LocaleConverter} types for
  -     *  the specified locale.
  -     */
  -    protected static FastHashMap lookup(Locale locale) {
  -        FastHashMap localeConverters;
  -
  -        if (locale == null) {
  -            localeConverters = (FastHashMap) mapConverters.get(defaultLocale);
  -        }
  -        else {
  -            localeConverters = (FastHashMap) mapConverters.get(locale);
  -
  -            if (localeConverters == null) {
  -                localeConverters = create(locale);
  -                mapConverters.put(locale, localeConverters);
  -            }
  -        }
  -
  -        return localeConverters;
  -    }
  -
  -    /**
  -     *  Create all {@link LocaleConverter} types for specified locale.
  -     *
  -     * @param locale The Locale
  -     * @return The FastHashMap instance contains the all {@link LocaleConverter} types
  -     *  for the specified locale.
  -     */
  -    protected static FastHashMap create(Locale locale) {
  -
  -        FastHashMap converter = new FastHashMap();
  -        converter.setFast(false);
  -
  -        converter.put(BigDecimal.class, new BigDecimalLocaleConverter(locale, applyLocalized));
  -        converter.put(BigInteger.class, new BigIntegerLocaleConverter(locale, applyLocalized));
  -
  -        converter.put(Byte.class, new ByteLocaleConverter(locale, applyLocalized));
  -        converter.put(Byte.TYPE, new ByteLocaleConverter(locale, applyLocalized));
  -
  -        converter.put(Double.class, new DoubleLocaleConverter(locale, applyLocalized));
  -        converter.put(Double.TYPE, new DoubleLocaleConverter(locale, applyLocalized));
  -
  -        converter.put(Float.class, new FloatLocaleConverter(locale, applyLocalized));
  -        converter.put(Float.TYPE, new FloatLocaleConverter(locale, applyLocalized));
  -
  -        converter.put(Integer.class, new IntegerLocaleConverter(locale, applyLocalized));
  -        converter.put(Integer.TYPE, new IntegerLocaleConverter(locale, applyLocalized));
  -
  -        converter.put(Long.class, new LongLocaleConverter(locale, applyLocalized));
  -        converter.put(Long.TYPE, new LongLocaleConverter(locale, applyLocalized));
  -
  -        converter.put(Short.class, new ShortLocaleConverter(locale, applyLocalized));
  -        converter.put(Short.TYPE, new ShortLocaleConverter(locale, applyLocalized));
  -
  -        converter.put(String.class, new StringLocaleConverter(locale, applyLocalized));
  -
  -        converter.put(Date.class, new SqlDateLocaleConverter(locale, applyLocalized));
  -        converter.put(Time.class, new SqlTimeLocaleConverter(locale, applyLocalized));
  -        converter.put(Timestamp.class, new SqlTimestampLocaleConverter(locale, applyLocalized));
  -
  -        converter.setFast(true);
  -
  -        return converter;
  -    }
  -}
  +/*
  + * $Header$
  + * $Revision$
  + * $Date$
  + *
  + * ====================================================================
  + *
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Group.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + *
  + */
  +
  +package org.apache.commons.beanutils.locale;
  +
  +import org.apache.commons.beanutils.locale.converters.*;
  +import org.apache.commons.collections.FastHashMap;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
  +
  +import java.lang.reflect.Array;
  +import java.math.BigDecimal;
  +import java.math.BigInteger;
  +import java.sql.Date;
  +import java.sql.Time;
  +import java.sql.Timestamp;
  +import java.util.Locale;
  +
  +/**
  + * <p>Utility methods for converting locale-sensitive String scalar values to objects of the
  + * specified Class, String arrays to arrays of the specified Class and
  + * object to locale-sensitive String scalar value.
  + *
  + * The actual {@link LocaleConverter} instance to be used
  + * can be registered for each possible destination Class. Unless you override them, standard
  + * {@link LocaleConverter} instances are provided for all of the following
  + * destination Classes:</p>
  + * <ul>
  + * <li>java.lang.BigDecimal</li>
  + * <li>java.lang.BigInteger</li>
  + * <li>byte and java.lang.Byte</li>
  + * <li>double and java.lang.Double</li>
  + * <li>float and java.lang.Float</li>
  + * <li>int and java.lang.Integer</li>
  + * <li>long and java.lang.Long</li>
  + * <li>short and java.lang.Short</li>
  + * <li>java.lang.String</li>
  + * <li>java.sql.Date</li>
  + * <li>java.sql.Time</li>
  + * <li>java.sql.Timestamp</li>
  + * </ul>
  + *
  + * <p>For backwards compatibility, the standard locale converters
  + * for primitive types (and the corresponding wrapper classes).
  + *
  + * If you prefer to have another {@link LocaleConverter}
  + * thrown instead, replace the standard {@link LocaleConverter} instances
  + * with ones created with the one of the appropriate constructors.
  + *
  + * It's important that {@link LocaleConverter} should be registered for
  + * the specified locale and Class (or primitive type).
  + *
  + * @author Yauheny Mikulski
  + */
  +public class LocaleConvertUtils {
  +
  +    // ----------------------------------------------------- Instance Variables
  +
  +    /** The locale - default for convertion. */
  +    private static Locale defaultLocale = Locale.getDefault();
  +
  +    /**
  +     * getter for defaultLocale
  +     */
  +    public static Locale getDefaultLocale() {
  +
  +        return defaultLocale;
  +    }
  +
  +    /**
  +     * setter for defaultLocale
  +     */
  +    public static void setDefaultLocale(Locale locale) {
  +
  +        if (locale == null) {
  +            defaultLocale = Locale.getDefault();
  +        }
  +        else {
  +            defaultLocale = locale;
  +        }
  +    }
  +
  +    /** Indicate whether the pattern is localized or not */
  +    private static boolean applyLocalized = false;
  +
  +    /**
  +     * getter for applyLocalized
  +     */
  +    public static boolean getApplyLocalized() {
  +        return applyLocalized;
  +    }
  +
  +    /**
  +     * setter for applyLocalized
  +     */
  +    public static void setApplyLocalized(boolean newApplyLocalized) {
  +        applyLocalized = newApplyLocalized;
  +    }
  +
  +    /** The <code>Log</code> instance for this class. */
  +    private static Log log = LogFactory.getLog(LocaleConvertUtils.class);
  +
  +    /** Every entry of the mapConverters is:
  +     *  key = locale
  +     *  value = FastHashMap of converters for the certain locale.
  +     */
  +    private static FastHashMap mapConverters = new FastHashMap();
  +
  +    /**
  +     * This code makes the state by default (deregisters all converters for all locales)
  +     *  and then registers default locale converters.
  +     */
  +    static {
  +        deregister();
  +    }
  +
  +    // --------------------------------------------------------- Methods
  +
  +    /**
  +     * Convert the specified locale-sensitive value into a String.
  +     *
  +     * @param value The Value to be converted
  +     *
  +     * @exception ConversionException if thrown by an underlying Converter
  +     */
  +    public static String convert(Object value) {
  +        return convert(value, defaultLocale, null);
  +    }
  +
  +    /**
  +     * Convert the specified locale-sensitive value into a String
  +     * using the convertion pattern.
  +     *
  +     * @param value The Value to be converted
  +     * @param pattern       The convertion pattern
  +     *
  +     * @exception ConversionException if thrown by an underlying Converter
  +     */
  +    public static String convert(Object value, String pattern) {
  +        return convert(value, defaultLocale, pattern);
  +    }
  +
  +    /**
  +     * Convert the specified locale-sensitive value into a String
  +     * using the paticular convertion pattern.
  +     *
  +     * @param value The Value to be converted
  +     * @param locale The locale
  +     * @param pattern The convertion pattern
  +     *
  +     * @exception ConversionException if thrown by an underlying Converter
  +     */
  +    public static String convert(Object value, Locale locale, String pattern) {
  +
  +        LocaleConverter converter = lookup(String.class, locale);
  +
  +        return (String) converter.convert(String.class, value, pattern);
  +    }
  +
  +    /**
  +     * Convert the specified value to an object of the specified class (if
  +     * possible).  Otherwise, return a String representation of the value.
  +     *
  +     * @param value The String scalar value to be converted
  +     * @param clazz The Data type to which this value should be converted.
  +     *
  +     * @exception ConversionException if thrown by an underlying Converter
  +     */
  +    public static Object convert(String value, Class clazz) {
  +
  +        return convert(value, clazz, defaultLocale, null);
  +    }
  +
  +    /**
  +     * Convert the specified value to an object of the specified class (if
  +     * possible) using the convertion pattern. Otherwise, return a String
  +     * representation of the value.
  +     *
  +     * @param value The String scalar value to be converted
  +     * @param clazz The Data type to which this value should be converted.
  +     * @param pattern The convertion pattern
  +     *
  +     * @exception ConversionException if thrown by an underlying Converter
  +     */
  +    public static Object convert(String value, Class clazz, String pattern) {
  +
  +        return convert(value, clazz, defaultLocale, pattern);
  +    }
  +
  +    /**
  +     * Convert the specified value to an object of the specified class (if
  +     * possible) using the convertion pattern. Otherwise, return a String
  +     * representation of the value.
  +     *
  +     * @param value The String scalar value to be converted
  +     * @param clazz The Data type to which this value should be converted.
  +     * @param locale The locale
  +     * @param pattern The convertion pattern
  +     *
  +     * @exception ConversionException if thrown by an underlying Converter
  +     */
  +    public static Object convert(String value, Class clazz, Locale locale, String pattern) {
  +
  +        if (log.isDebugEnabled()) {
  +            log.debug("Convert string " + value + " to class " +
  +                    clazz.getName() + " using " + locale.toString() +
  +                    " locale and " + pattern + " pattern");
  +        }
  +
  +        LocaleConverter converter = lookup(clazz, locale);
  +
  +        if (converter == null) {
  +            converter = (LocaleConverter) lookup(String.class, locale);
  +        }
  +        if (log.isTraceEnabled()) {
  +            log.trace("  Using converter " + converter);
  +        }
  +
  +        return (converter.convert(clazz, value, pattern));
  +    }
  +
  +    /**
  +     * Convert an array of specified values to an array of objects of the
  +     * specified class (if possible) using the convertion pattern.
  +     *
  +     * @param values Value to be converted (may be null)
  +     * @param clazz Java array or element class to be converted to
  +     * @param pattern The convertion pattern
  +     *
  +     * @exception ConversionException if thrown by an underlying Converter
  +     */
  +    public static Object convert(String values[], Class clazz, String pattern) {
  +
  +        return convert(values, clazz, getDefaultLocale(), pattern);
  +    }
  +
  +    /**
  +     * Convert an array of specified values to an array of objects of the
  +     * specified class (if possible) using the convertion pattern.
  +     *
  +     * @param values Value to be converted (may be null)
  +     * @param clazz Java array or element class to be converted to
  +     * @param locale The locale
  +     * @param pattern The convertion pattern
  +     *
  +     * @exception ConversionException if thrown by an underlying Converter
  +     */
  +    public static Object convert(String values[], Class clazz, Locale locale, String pattern) {
  +
  +        Class type = clazz;
  +        if (clazz.isArray()) {
  +            type = clazz.getComponentType();
  +        }
  +        if (log.isDebugEnabled()) {
  +            log.debug("Convert String[" + values.length + "] to class " +
  +                    type.getName() + "[] using " + locale.toString() +
  +                    " locale and " + pattern + " pattern");
  +        }
  +
  +        Object array = Array.newInstance(type, values.length);
  +        for (int i = 0; i < values.length; i++) {
  +            Array.set(array, i, convert(values[i], type, locale, pattern));
  +        }
  +
  +        return (array);
  +    }
  +
  +    /**
  +     * Register a custom {@link LocaleConverter} for the specified destination
  +     * <code>Class</code>, replacing any previously registered converter.
  +     *
  +     * @param converter The LocaleConverter to be registered
  +     * @param clazz The Destination class for conversions performed by this
  +     *  Converter
  +     * @param locale The locale
  +     */
  +    public static void register(LocaleConverter converter, Class clazz, Locale locale) {
  +
  +        lookup(locale).put(clazz, converter);
  +    }
  +
  +    /**
  +     * Remove any registered {@link LocaleConverter}.
  +     */
  +    public static void deregister() {
  +
  +        FastHashMap defaultConverter = lookup(defaultLocale);
  +
  +        mapConverters.setFast(false);
  +
  +        mapConverters.clear();
  +        mapConverters.put(defaultLocale, defaultConverter);
  +
  +        mapConverters.setFast(true);
  +    }
  +
  +
  +    /**
  +     * Remove any registered {@link LocaleConverter} for the specified locale
  +     *
  +     * @param locale The locale
  +     */
  +    public static void deregister(Locale locale) {
  +
  +        mapConverters.remove(locale);
  +    }
  +
  +
  +    /**
  +     * Remove any registered {@link LocaleConverter} for the specified locale and Class.
  +     *
  +     * @param clazz Class for which to remove a registered Converter
  +     * @param locale The locale
  +     */
  +    public static void deregister(Class clazz, Locale locale) {
  +
  +        lookup(locale).remove(clazz);
  +    }
  +
  +    /**
  +     * Look up and return any registered {@link LocaleConverter} for the specified
  +     * destination class and locale; if there is no registered Converter, return
  +     * <code>null</code>.
  +     *
  +     * @param clazz Class for which to return a registered Converter
  +     * @param locale The Locale
  +     */
  +    public static LocaleConverter lookup(Class clazz, Locale locale) {
  +
  +        return (LocaleConverter) lookup(locale).get(clazz);
  +    }
  +
  +    /**
  +     * Look up and return any registered FastHashMap instance for the specified locale;
  +     * if there is no registered one, return <code>null</code>.
  +     *
  +     * @param locale The Locale
  +     * @return The FastHashMap instance contains the all {@link LocaleConverter} types for
  +     *  the specified locale.
  +     */
  +    protected static FastHashMap lookup(Locale locale) {
  +        FastHashMap localeConverters;
  +
  +        if (locale == null) {
  +            localeConverters = (FastHashMap) mapConverters.get(defaultLocale);
  +        }
  +        else {
  +            localeConverters = (FastHashMap) mapConverters.get(locale);
  +
  +            if (localeConverters == null) {
  +                localeConverters = create(locale);
  +                mapConverters.put(locale, localeConverters);
  +            }
  +        }
  +
  +        return localeConverters;
  +    }
  +
  +    /**
  +     *  Create all {@link LocaleConverter} types for specified locale.
  +     *
  +     * @param locale The Locale
  +     * @return The FastHashMap instance contains the all {@link LocaleConverter} types
  +     *  for the specified locale.
  +     */
  +    protected static FastHashMap create(Locale locale) {
  +
  +        FastHashMap converter = new FastHashMap();
  +        converter.setFast(false);
  +
  +        converter.put(BigDecimal.class, new BigDecimalLocaleConverter(locale, applyLocalized));
  +        converter.put(BigInteger.class, new BigIntegerLocaleConverter(locale, applyLocalized));
  +
  +        converter.put(Byte.class, new ByteLocaleConverter(locale, applyLocalized));
  +        converter.put(Byte.TYPE, new ByteLocaleConverter(locale, applyLocalized));
  +
  +        converter.put(Double.class, new DoubleLocaleConverter(locale, applyLocalized));
  +        converter.put(Double.TYPE, new DoubleLocaleConverter(locale, applyLocalized));
  +
  +        converter.put(Float.class, new FloatLocaleConverter(locale, applyLocalized));
  +        converter.put(Float.TYPE, new FloatLocaleConverter(locale, applyLocalized));
  +
  +        converter.put(Integer.class, new IntegerLocaleConverter(locale, applyLocalized));
  +        converter.put(Integer.TYPE, new IntegerLocaleConverter(locale, applyLocalized));
  +
  +        converter.put(Long.class, new LongLocaleConverter(locale, applyLocalized));
  +        converter.put(Long.TYPE, new LongLocaleConverter(locale, applyLocalized));
  +
  +        converter.put(Short.class, new ShortLocaleConverter(locale, applyLocalized));
  +        converter.put(Short.TYPE, new ShortLocaleConverter(locale, applyLocalized));
  +
  +        converter.put(String.class, new StringLocaleConverter(locale, applyLocalized));
  +
  +        converter.put(Date.class, new SqlDateLocaleConverter(locale, applyLocalized));
  +        converter.put(Time.class, new SqlTimeLocaleConverter(locale, applyLocalized));
  +        converter.put(Timestamp.class, new SqlTimestampLocaleConverter(locale, applyLocalized));
  +
  +        converter.setFast(true);
  +
  +        return converter;
  +    }
  +}
  
  
  
  1.2       +90 -90    jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/locale/LocaleConverter.java
  
  Index: LocaleConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/locale/LocaleConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LocaleConverter.java	3 Sep 2002 21:34:20 -0000	1.1
  +++ LocaleConverter.java	11 Jan 2003 22:02:15 -0000	1.2
  @@ -1,90 +1,90 @@
  -/*
  - * $Header$
  - * $Revision$
  - * $Date$
  - *
  - * ====================================================================
  - *
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  - *
  - * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written
  - *    permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - *
  - */
  -
  -package org.apache.commons.beanutils.locale;
  -
  -import org.apache.commons.beanutils.Converter;
  -
  -
  -/**
  - * <p>General purpose locale-sensitive data type converter that can be registered and used
  - * within the BeanUtils package to manage the conversion of objects from
  - * one type to another.
  - *
  - * @author Yauheny Mikulski
  - */
  -
  -public interface LocaleConverter extends Converter {
  -
  -
  -    /**
  -     * Convert the specified locale-sensitive input object into an output object of the
  -     * specified type.
  -     *
  -     * @param type Data type to which this value should be converted
  -     * @param value The input value to be converted
  -     * @param pattern The user-defined pattern is used for the input object formatting.
  -     *
  -     * @exception ConversionException if conversion cannot be performed
  -     *  successfully
  -     */
  -    public Object convert(Class type, Object value, String pattern);
  -}
  +/*
  + * $Header$
  + * $Revision$
  + * $Date$
  + *
  + * ====================================================================
  + *
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Group.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + *
  + */
  +
  +package org.apache.commons.beanutils.locale;
  +
  +import org.apache.commons.beanutils.Converter;
  +
  +
  +/**
  + * <p>General purpose locale-sensitive data type converter that can be registered and used
  + * within the BeanUtils package to manage the conversion of objects from
  + * one type to another.
  + *
  + * @author Yauheny Mikulski
  + */
  +
  +public interface LocaleConverter extends Converter {
  +
  +
  +    /**
  +     * Convert the specified locale-sensitive input object into an output object of the
  +     * specified type.
  +     *
  +     * @param type Data type to which this value should be converted
  +     * @param value The input value to be converted
  +     * @param pattern The user-defined pattern is used for the input object formatting.
  +     *
  +     * @exception ConversionException if conversion cannot be performed
  +     *  successfully
  +     */
  +    public Object convert(Class type, Object value, String pattern);
  +}
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>