    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *      http://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017
    018package org.apache.commons.beanutils.locale;
    019
    020import java.lang.reflect.InvocationTargetException;
    021import java.util.Locale;
    022
    023import org.apache.commons.beanutils.BeanUtils;
    024
    025/**
    026 * <p>Utility methods for populating JavaBeans properties
    027 * via reflection in a locale-dependent manner.</p>
    028 *
    029 * <p>The implementations for these methods are provided by <code>LocaleBeanUtilsBean</code>.
    030 * For more details see {@link LocaleBeanUtilsBean}.</p>
    031 *
    032 */
    033
    034public class LocaleBeanUtils extends BeanUtils {
    035
    036    /** @deprecated moved into <code>LocaleBeanUtils</code> */
    037    @Deprecated
    038    protected static class Descriptor {
    039
    040        private int index = -1;    // Indexed subscript value (if any)
    041        private String name;
    042        private String propName;   // Simple name of target property
    043        private String key;        // Mapped key value (if any)
    044        private Object target;
    045
    046        /**
    047         * Construct a descriptor instance for the target bean and property.
    048         *
    049         * @param target The target bean
    050         * @param name The property name (includes indexed/mapped expr)
    051         * @param propName The property name
    052         * @param key The mapped property key (if any)
    053         * @param index The indexed property index (if any)
    054         */
    055        public Descriptor(final Object target, final String name, final String propName, final String key, final int index) {
    056
    057            setTarget(target);
    058            setName(name);
    059            setPropName(propName);
    060            setKey(key);
    061            setIndex(index);
    062        }
    063
    064        /**
    065         * Return indexed property index.
    066         *
    067         * @return indexed property index (if any)
    068         */
    069        public int getIndex() {
    070            return index;
    071        }
    072
    073        /**
    074         * Return the mapped property key.
    075         *
    076         * @return the mapped property key (if any)
    077         */
    078        public String getKey() {
    079            return key;
    080        }
    081
    082        /**
    083         * Return property name (includes indexed/mapped expr).
    084         *
    085         * @return The property name (includes indexed/mapped expr)
    086         */
    087        public String getName() {
    088            return name;
    089        }
    090
    091        /**
    092         * Return the property name.
    093         *
    094         * @return The property name
    095         */
    096        public String getPropName() {
    097            return propName;
    098        }
    099
    100        /**
    101         * Return the target bean.
    102         *
    103         * @return The descriptors target bean
    104         */
    105        public Object getTarget() {
    106            return target;
    107        }
    108
    109        /**
    110         * Set the indexed property index.
    111         *
    112         * @param index The indexed property index (if any)
    113         */
    114        public void setIndex(final int index) {
    115            this.index = index;
    116        }
    117
    118        /**
    119         * Set the mapped property key.
    120         *
    121         * @param key The mapped property key (if any)
    122         */
    123        public void setKey(final String key) {
    124            this.key = key;
    125        }
    126
    127        /**
    128         * Set the property name (includes indexed/mapped expr).
    129         *
    130         * @param name The property name (includes indexed/mapped expr)
    131         */
    132        public void setName(final String name) {
    133            this.name = name;
    134        }
    135
    136        /**
    137         * Set the property name.
    138         *
    139         * @param propName The property name
    140         */
    141        public void setPropName(final String propName) {
    142            this.propName = propName;
    143        }
    144
    145        /**
    146         * Set the target bean.
    147         *
    148         * @param target The target bean
    149         */
    150        public void setTarget(final Object target) {
    151            this.target = target;
    152        }
    153    }
    154
    155    /**
    156     * Resolve any nested expression to get the actual target bean.
    157     *
    158     * @deprecated moved into <code>LocaleBeanUtilsBean</code>
    159     * @param bean The bean
    160     * @param name The property name
    161     * @return The property's descriptor
    162     * @throws IllegalAccessException if the caller does not have
    163     *  access to the property accessor method
    164     * @throws InvocationTargetException if the property accessor method
    165     *  throws an exception
    166     */
    167    @Deprecated
    168    protected static Descriptor calculate(final Object bean, final String name)
    169            throws IllegalAccessException, InvocationTargetException {
    170
    171        final org.apache.commons.beanutils.locale.LocaleBeanUtilsBean.Descriptor descriptor
    172            = LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().calculate(bean, name);
    173        return new Descriptor(
    174                descriptor.getTarget(),
    175                descriptor.getName(),
    176                descriptor.getPropName(),
    177                descriptor.getKey(),
    178                descriptor.getIndex());
    179    }
    180
    181    /**
    182     * <p>Convert the specified value to the required type.</p>
    183     *
    184     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    185     *
    186     * @param type The Java type of target property
    187     * @param index The indexed subscript value (if any)
    188     * @param value The value to be converted
    189     * @return The converted value
    190     * @see LocaleBeanUtilsBean#convert(Class, int, Object)
    191     */
    192    protected static Object convert(final Class<?> type, final int index, final Object value) {
    193
    194        return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().convert(type, index, value);
    195    }
    196
    197    /**
    198     * <p>Convert the specified value to the required type using the
    199     * specified conversion pattern.</p>
    200     *
    201     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    202     *
    203     * @param type The Java type of target property
    204     * @param index The indexed subscript value (if any)
    205     * @param value The value to be converted
    206     * @param pattern The conversion pattern
    207     * @return The converted value
    208     * @see LocaleBeanUtilsBean#convert(Class, int, Object, String)
    209     */
    210    protected static Object convert(final Class<?> type, final int index, final Object value, final String pattern) {
    211
    212        return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().convert(type, index, value, pattern);
    213    }
    214
    215    /**
    216     * <p>Calculate the property type.</p>
    217     *
    218     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    219     *
    220     * @param target The bean
    221     * @param name The property name
    222     * @param propName The Simple name of target property
    223     * @return The property's type
    224     * @throws IllegalAccessException if the caller does not have
    225     *  access to the property accessor method
    226     * @throws InvocationTargetException if the property accessor method
    227     *  throws an exception
    228     *
    229     * @see LocaleBeanUtilsBean#definePropertyType(Object, String, String)
    230     */
    231    protected static Class<?> definePropertyType(final Object target, final String name, final String propName)
    232            throws IllegalAccessException, InvocationTargetException {
    233
    234        return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().definePropertyType(target, name, propName);
    235    }
    236
    237    /**
    238     * <p>Gets whether the pattern is localized or not.</p>
    239     *
    240     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    241     *
    242     * @return <code>true</code> if pattern is localized,
    243     * otherwise <code>false</code>
    244     * @see LocaleBeanUtilsBean#getApplyLocalized()
    245     */
    246    public static boolean getApplyLocalized() {
    247
    248        return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getApplyLocalized();
    249    }
    250
    251    /**
    252     * <p>Gets the locale used when no locale is passed.</p>
    253     *
    254     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    255     *
    256     * @return the default locale
    257     * @see LocaleBeanUtilsBean#getDefaultLocale()
    258     */
    259    public static Locale getDefaultLocale() {
    260
    261        return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getDefaultLocale();
    262    }
    263
    264    /**
    265     * Return the value of the specified locale-sensitive indexed property
    266     * of the specified bean, as a String using the default conversion pattern of
    267     * the corresponding {@link LocaleConverter}.
    268     *
    269     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    270     *
    271     * @param bean Bean whose property is to be extracted
    272     * @param name <code>propertyname[index]</code> of the property value
    273     *  to be extracted
    274     * @return The indexed property's value, converted to a String
    275     * @throws IllegalAccessException if the caller does not have
    276     *  access to the property accessor method
    277     * @throws InvocationTargetException if the property accessor method
    278     *  throws an exception
    279     * @throws NoSuchMethodException if an accessor method for this
    280     *  propety cannot be found
    281     *
    282     * @see LocaleBeanUtilsBean#getIndexedProperty(Object, String)
    283     */
    284    public static String getIndexedProperty(final Object bean, final String name)
    285            throws IllegalAccessException, InvocationTargetException,
    286            NoSuchMethodException {
    287
    288        return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getIndexedProperty(bean, name);
    289    }
    290
    291    /**
    292     * <p>Return the value of the specified locale-sensetive indexed property
    293     * of the specified bean, as a String using the default conversion pattern of
    294     * the corresponding {@link LocaleConverter}.</p>
    295     *
    296     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    297     *
    298     * @param bean Bean whose property is to be extracted
    299     * @param name Simple property name of the property value to be extracted
    300     * @param index Index of the property value to be extracted
    301     * @return The indexed property's value, converted to a String
    302     * @throws IllegalAccessException if the caller does not have
    303     *  access to the property accessor method
    304     * @throws InvocationTargetException if the property accessor method
    305     *  throws an exception
    306     * @throws NoSuchMethodException if an accessor method for this
    307     *  propety cannot be found
    308     *
    309     * @see LocaleBeanUtilsBean#getIndexedProperty(Object, String, int)
    310     */
    311    public static String getIndexedProperty(final Object bean,
    312                                            final String name, final int index)
    313            throws IllegalAccessException, InvocationTargetException,
    314            NoSuchMethodException {
    315        return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getIndexedProperty(bean, name, index);
    316    }
    317
    318    /**
    319     * <p>Return the value of the specified locale-sensetive indexed property
    320     * of the specified bean, as a String using the specified conversion pattern.</p>
    321     *
    322     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    323     *
    324     * @param bean Bean whose property is to be extracted
    325     * @param name Simple property name of the property value to be extracted
    326     * @param index Index of the property value to be extracted
    327     * @param pattern The conversion pattern
    328     * @return The indexed property's value, converted to a String
    329     * @throws IllegalAccessException if the caller does not have
    330     *  access to the property accessor method
    331     * @throws InvocationTargetException if the property accessor method
    332     *  throws an exception
    333     * @throws NoSuchMethodException if an accessor method for this
    334     *  propety cannot be found
    335     *
    336     * @see LocaleBeanUtilsBean#getIndexedProperty(Object, String, int, String)
    337     */
    338    public static String getIndexedProperty(final Object bean,
    339                                            final String name, final int index, final String pattern)
    340            throws IllegalAccessException, InvocationTargetException,
    341            NoSuchMethodException {
    342
    343        return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getIndexedProperty(bean, name, index, pattern);
    344    }
    345
    346    /**
    347     * <p>Return the value of the specified locale-sensitive indexed property
    348     * of the specified bean, as a String.</p>
    349     *
    350     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    351     *
    352     * @param bean Bean whose property is to be extracted
    353     * @param name <code>propertyname[index]</code> of the property value
    354     *  to be extracted
    355     * @param pattern The conversion pattern
    356     * @return The indexed property's value, converted to a String
    357     * @throws IllegalAccessException if the caller does not have
    358     *  access to the property accessor method
    359     * @throws InvocationTargetException if the property accessor method
    360     *  throws an exception
    361     * @throws NoSuchMethodException if an accessor method for this
    362     *  propety cannot be found
    363     *
    364     * @see LocaleBeanUtilsBean#getIndexedProperty(Object, String, String)
    365     */
    366    public static String getIndexedProperty(final Object bean, final String name, final String pattern)
    367            throws IllegalAccessException, InvocationTargetException,
    368            NoSuchMethodException {
    369
    370        return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getIndexedProperty(bean, name, pattern);
    371    }
    372
    373    /**
    374     * <p>Return the value of the specified locale-sensitive mapped property
    375     * of the specified bean, as a String using the default
    376     * conversion pattern of the corresponding {@link LocaleConverter}.</p>
    377     *
    378     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    379     *
    380     * @param bean Bean whose property is to be extracted
    381     * @param name <code>propertyname(index)</code> of the property value
    382     *  to be extracted
    383     * @return The mapped property's value, converted to a String
    384     * @throws IllegalAccessException if the caller does not have
    385     *  access to the property accessor method
    386     * @throws InvocationTargetException if the property accessor method
    387     *  throws an exception
    388     * @throws NoSuchMethodException if an accessor method for this
    389     *  propety cannot be found
    390     *
    391     * @see LocaleBeanUtilsBean#getMappedProperty(Object, String)
    392     */
    393    public static String getMappedProperty(final Object bean, final String name)
    394            throws IllegalAccessException, InvocationTargetException,
    395            NoSuchMethodException {
    396
    397        return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getMappedProperty(bean, name);
    398    }
    399
    400    /**
    401     * <p>Return the value of the specified mapped locale-sensitive property
    402     * of the specified bean, as a String
    403     * The key is specified as a method parameter and must *not* be included
    404     * in the property name expression.</p>
    405     *
    406     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    407     *
    408     * @param bean Bean whose property is to be extracted
    409     * @param name Simple property name of the property value to be extracted
    410     * @param key Lookup key of the property value to be extracted
    411     * @return The mapped property's value, converted to a String
    412     * @throws IllegalAccessException if the caller does not have
    413     *  access to the property accessor method
    414     * @throws InvocationTargetException if the property accessor method
    415     *  throws an exception
    416     * @throws NoSuchMethodException if an accessor method for this
    417     *  propety cannot be found
    418     *
    419     * @see LocaleBeanUtilsBean#getMappedProperty(Object, String, String)
    420     */
    421    public static String getMappedProperty(final Object bean,
    422                                           final String name, final String key)
    423            throws IllegalAccessException, InvocationTargetException,
    424            NoSuchMethodException {
    425
    426        return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getMappedProperty(bean, name, key);
    427    }
    428
    429    /**
    430     * <p>Return the value of the specified mapped locale-sensitive property
    431     * of the specified bean, as a String using the specified conversion pattern.</p>
    432     *
    433     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    434     *
    435     * @param bean Bean whose property is to be extracted
    436     * @param name Simple property name of the property value to be extracted
    437     * @param key Lookup key of the property value to be extracted
    438     * @param pattern The conversion pattern
    439     * @return The mapped property's value, converted to a String
    440     * @throws IllegalAccessException if the caller does not have
    441     *  access to the property accessor method
    442     * @throws InvocationTargetException if the property accessor method
    443     *  throws an exception
    444     * @throws NoSuchMethodException if an accessor method for this
    445     *  propety cannot be found
    446     *
    447     * @see LocaleBeanUtilsBean#getMappedProperty(Object, String, String, String)
    448     */
    449    public static String getMappedProperty(final Object bean,
    450                                           final String name, final String key, final String pattern)
    451            throws IllegalAccessException, InvocationTargetException,
    452            NoSuchMethodException {
    453
    454        return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getMappedProperty(bean, name, key, pattern);
    455    }
    456
    457    /**
    458     * <p>Return the value of the specified locale-sensitive mapped property
    459     * of the specified bean, as a String using the specified pattern.</p>
    460     *
    461     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    462     *
    463     * @param bean Bean whose property is to be extracted
    464     * @param name <code>propertyname(index)</code> of the property value
    465     *  to be extracted
    466     * @param pattern The conversion pattern
    467     * @return The mapped property's value, converted to a String
    468     * @throws IllegalAccessException if the caller does not have
    469     *  access to the property accessor method
    470     * @throws InvocationTargetException if the property accessor method
    471     *  throws an exception
    472     * @throws NoSuchMethodException if an accessor method for this
    473     *  propety cannot be found
    474     *
    475     * @see LocaleBeanUtilsBean#getMappedPropertyLocale(Object, String, String)
    476     */
    477    public static String getMappedPropertyLocale(final Object bean, final String name, final String pattern)
    478            throws IllegalAccessException, InvocationTargetException,
    479            NoSuchMethodException {
    480
    481        return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getMappedPropertyLocale(bean, name, pattern);
    482    }
    483
    484    /**
    485     * <p>Return the value of the (possibly nested) locale-sensitive property
    486     * of the specified name.</p>
    487     *
    488     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    489     *
    490     * @param bean Bean whose property is to be extracted
    491     * @param name Possibly nested name of the property to be extracted
    492     * @return The nested property's value, converted to a String
    493     * @throws IllegalAccessException if the caller does not have
    494     *  access to the property accessor method
    495     * @throws InvocationTargetException if the property accessor method
    496     *  throws an exception
    497     * @throws NoSuchMethodException if an accessor method for this
    498     *  propety cannot be found
    499     *
    500     * @see LocaleBeanUtilsBean#getNestedProperty(Object, String)
    501     */
    502    public static String getNestedProperty(final Object bean, final String name)
    503            throws IllegalAccessException, InvocationTargetException,
    504            NoSuchMethodException {
    505
    506        return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getNestedProperty(bean, name);
    507    }
    508
    509    /**
    510     * <p>Return the value of the (possibly nested) locale-sensitive property
    511     * of the specified name, for the specified bean,
    512     * as a String using the specified pattern.</p>
    513     *
    514     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    515     *
    516     * @param bean Bean whose property is to be extracted
    517     * @param name Possibly nested name of the property to be extracted
    518     * @param pattern The conversion pattern
    519     * @return The nested property's value, converted to a String
    520     * @throws IllegalAccessException if the caller does not have
    521     *  access to the property accessor method
    522     * @throws InvocationTargetException if the property accessor method
    523     *  throws an exception
    524     * @throws NoSuchMethodException if an accessor method for this
    525     *  propety cannot be found
    526     *
    527     * @see LocaleBeanUtilsBean#getNestedProperty(Object, String, String)
    528     */
    529    public static String getNestedProperty(final Object bean, final String name, final String pattern)
    530            throws IllegalAccessException, InvocationTargetException,
    531            NoSuchMethodException {
    532
    533        return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getNestedProperty(bean, name, pattern);
    534    }
    535
    536    /**
    537     * <p>Return the value of the specified locale-sensitive property
    538     * of the specified bean.</p>
    539     *
    540     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    541     *
    542     * @param bean Bean whose property is to be extracted
    543     * @param name Possibly indexed and/or nested name of the property
    544     *  to be extracted
    545     * @return The property's value, converted to a String
    546     * @throws IllegalAccessException if the caller does not have
    547     *  access to the property accessor method
    548     * @throws InvocationTargetException if the property accessor method
    549     *  throws an exception
    550     * @throws NoSuchMethodException if an accessor method for this
    551     *  propety cannot be found
    552     *
    553     * @see LocaleBeanUtilsBean#getProperty(Object, String)
    554     */
    555    public static String getProperty(final Object bean, final String name)
    556            throws IllegalAccessException, InvocationTargetException,
    557            NoSuchMethodException {
    558
    559        return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getProperty(bean, name);
    560    }
    561
    562    /**
    563     * <p>Return the value of the specified locale-sensitive property
    564     * of the specified bean.</p>
    565     *
    566     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    567     *
    568     * @param bean Bean whose property is to be extracted
    569     * @param name Possibly indexed and/or nested name of the property
    570     *  to be extracted
    571     * @param pattern The conversion pattern
    572     * @return The nested property's value, converted to a String
    573     * @throws IllegalAccessException if the caller does not have
    574     *  access to the property accessor method
    575     * @throws InvocationTargetException if the property accessor method
    576     *  throws an exception
    577     * @throws NoSuchMethodException if an accessor method for this
    578     *  propety cannot be found
    579     *
    580     * @see LocaleBeanUtilsBean#getProperty(Object, String, String)
    581     */
    582    public static String getProperty(final Object bean, final String name, final String pattern)
    583            throws IllegalAccessException, InvocationTargetException,
    584            NoSuchMethodException {
    585
    586        return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getProperty(bean, name, pattern);
    587    }
    588
    589    /**
    590     * <p>Return the value of the specified simple locale-sensitive property
    591     * of the specified bean, converted to a String using the default
    592     * conversion pattern of the corresponding {@link LocaleConverter}.</p>
    593     *
    594     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    595     *
    596     * @param bean Bean whose property is to be extracted
    597     * @param name Name of the property to be extracted
    598     * @return The property's value, converted to a String
    599     * @throws IllegalAccessException if the caller does not have
    600     *  access to the property accessor method
    601     * @throws InvocationTargetException if the property accessor method
    602     *  throws an exception
    603     * @throws NoSuchMethodException if an accessor method for this
    604     *  propety cannot be found
    605     *
    606     * @see LocaleBeanUtilsBean#getSimpleProperty(Object, String)
    607     */
    608    public static String getSimpleProperty(final Object bean, final String name)
    609            throws IllegalAccessException, InvocationTargetException,
    610            NoSuchMethodException {
    611
    612        return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getSimpleProperty(bean, name);
    613    }
    614
    615    /**
    616     * <p>Return the value of the specified simple locale-sensitive property
    617     * of the specified bean, converted to a String using the specified
    618     * conversion pattern.</p>
    619     *
    620     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    621     *
    622     * @param bean Bean whose property is to be extracted
    623     * @param name Name of the property to be extracted
    624     * @param pattern The conversion pattern
    625     * @return The property's value, converted to a String
    626     * @throws IllegalAccessException if the caller does not have
    627     *  access to the property accessor method
    628     * @throws InvocationTargetException if the property accessor method
    629     *  throws an exception
    630     * @throws NoSuchMethodException if an accessor method for this
    631     *  propety cannot be found
    632     *
    633     * @see LocaleBeanUtilsBean#getSimpleProperty(Object, String, String)
    634     */
    635    public static String getSimpleProperty(final Object bean, final String name, final String pattern)
    636            throws IllegalAccessException, InvocationTargetException,
    637            NoSuchMethodException {
    638
    639        return LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().getSimpleProperty(bean, name, pattern);
    640    }
    641
    642    /**
    643     * <p>Invoke the setter method.</p>
    644     *
    645     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    646     *
    647     * @param target The bean
    648     * @param propName The Simple name of target property
    649     * @param key The Mapped key value (if any)
    650     * @param index The indexed subscript value (if any)
    651     * @param newValue The value to be set
    652     * @throws IllegalAccessException if the caller does not have
    653     *  access to the property accessor method
    654     * @throws InvocationTargetException if the property accessor method
    655     *  throws an exception
    656     *
    657     * @see LocaleBeanUtilsBean#invokeSetter(Object, String, String, int, Object)
    658     */
    659    protected static void invokeSetter(final Object target, final String propName, final String key, final int index, final Object newValue)
    660            throws IllegalAccessException, InvocationTargetException {
    661
    662       LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().invokeSetter(target, propName, key, index, newValue);
    663    }
    664
    665    /**
    666     * <p>Sets whether the pattern is localized or not.</p>
    667     *
    668     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    669     *
    670     * @param newApplyLocalized <code>true</code> if pattern is localized,
    671     * otherwise <code>false</code>
    672     * @see LocaleBeanUtilsBean#setApplyLocalized(boolean)
    673     */
    674    public static void setApplyLocalized(final boolean newApplyLocalized) {
    675
    676        LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().setApplyLocalized(newApplyLocalized);
    677    }
    678
    679    /**
    680     * <p>Sets the locale used when no locale is passed.</p>
    681     *
    682     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    683     *
    684     * @param locale the default locale
    685     * @see LocaleBeanUtilsBean#setDefaultLocale(Locale)
    686     */
    687    public static void setDefaultLocale(final Locale locale) {
    688
    689        LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().setDefaultLocale(locale);
    690    }
    691
    692    /**
    693     * <p>Set the specified locale-sensitive property value, performing type
    694     * conversions as required to conform to the type of the destination property
    695     * using the default conversion pattern of the corresponding {@link LocaleConverter}.</p>
    696     *
    697     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    698     *
    699     * @param bean Bean on which setting is to be performed
    700     * @param name Property name (can be nested/indexed/mapped/combo)
    701     * @param value Value to be set
    702     * @throws IllegalAccessException if the caller does not have
    703     *  access to the property accessor method
    704     * @throws InvocationTargetException if the property accessor method
    705     *  throws an exception
    706     *
    707     * @see LocaleBeanUtilsBean#setProperty(Object, String, Object)
    708     */
    709    public static void setProperty(final Object bean, final String name, final Object value)
    710            throws IllegalAccessException, InvocationTargetException {
    711
    712        LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().setProperty(bean, name, value);
    713    }
    714
    715    /**
    716     * <p>Set the specified locale-sensitive property value, performing type
    717     * conversions as required to conform to the type of the destination
    718     * property using the specified conversion pattern.</p>
    719     *
    720     * <p>For more details see <code>LocaleBeanUtilsBean</code></p>
    721     *
    722     * @param bean Bean on which setting is to be performed
    723     * @param name Property name (can be nested/indexed/mapped/combo)
    724     * @param value Value to be set
    725     * @param pattern The conversion pattern
    726     * @throws IllegalAccessException if the caller does not have
    727     *  access to the property accessor method
    728     * @throws InvocationTargetException if the property accessor method
    729     *  throws an exception
    730     *
    731     * @see LocaleBeanUtilsBean#setProperty(Object, String, Object, String)
    732     */
    733    public static void setProperty(final Object bean, final String name, final Object value, final String pattern)
    734            throws IllegalAccessException, InvocationTargetException {
    735
    736        LocaleBeanUtilsBean.getLocaleBeanUtilsInstance().setProperty(bean, name, value, pattern);
    737     }
    738}
    739