    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
    018
    019    package org.apache.commons.beanutils;
    020
    021    import java.beans.PropertyDescriptor;
    022    import java.lang.reflect.InvocationTargetException;
    023    import java.lang.reflect.Method;
    024    import java.util.Map;
    025
    026    import org.apache.commons.collections.FastHashMap;
    027
    028
    029    /**
    030     * <p>Utility methods for using Java Reflection APIs to facilitate generic
    031     * property getter and setter operations on Java objects.</p>
    032     *
    033     * <p>The implementations for these methods are provided by <code>PropertyUtilsBean</code>.
    034     * For more details see {@link PropertyUtilsBean}.</p>
    035     *
    036     * @author Craig R. McClanahan
    037     * @author Ralph Schaer
    038     * @author Chris Audley
    039     * @author Rey Francois
    040     * @author Gregor Rayman
    041     * @author Jan Sorensen
    042     * @author Scott Sanders
    043     * @version $Revision: 644137 $ $Date: 2008-04-03 03:30:23 +0100 (Thu, 03 Apr 2008) $
    044     * @see PropertyUtilsBean
    045     * @see org.apache.commons.beanutils.expression.Resolver
    046     */
    047
    048    public class PropertyUtils {
    049
    050
    051        // ----------------------------------------------------- Manifest Constants
    052
    053
    054        /**
    055         * The delimiter that preceeds the zero-relative subscript for an
    056         * indexed reference.
    057         *
    058         * @deprecated The notation used for property name expressions is now
    059         * dependant on the {@link org.apache.commons.beanutils.expression.Resolver}
    060         * implementation being used.
    061         */
    062        public static final char INDEXED_DELIM = '[';
    063
    064
    065        /**
    066         * The delimiter that follows the zero-relative subscript for an
    067         * indexed reference.
    068         *
    069         * @deprecated The notation used for property name expressions is now
    070         * dependant on the {@link org.apache.commons.beanutils.expression.Resolver}
    071         * implementation being used.
    072         */
    073        public static final char INDEXED_DELIM2 = ']';
    074
    075
    076        /**
    077         * The delimiter that preceeds the key of a mapped property.
    078         *
    079         * @deprecated The notation used for property name expressions is now
    080         * dependant on the {@link org.apache.commons.beanutils.expression.Resolver}
    081         * implementation being used.
    082         */
    083        public static final char MAPPED_DELIM = '(';
    084
    085
    086        /**
    087         * The delimiter that follows the key of a mapped property.
    088         *
    089         * @deprecated The notation used for property name expressions is now
    090         * dependant on the {@link org.apache.commons.beanutils.expression.Resolver}
    091         * implementation being used.
    092         */
    093        public static final char MAPPED_DELIM2 = ')';
    094
    095
    096        /**
    097         * The delimiter that separates the components of a nested reference.
    098         *
    099         * @deprecated The notation used for property name expressions is now
    100         * dependant on the {@link org.apache.commons.beanutils.expression.Resolver}
    101         * implementation being used.
    102         */
    103        public static final char NESTED_DELIM = '.';
    104
    105
    106        // ------------------------------------------------------- Static Variables
    107
    108
    109        /**
    110         * The debugging detail level for this component.
    111         *
    112         * Note that this static variable will have unexpected side-effects if
    113         * this class is deployed in a shared classloader within a container.
    114         * However as it is actually completely ignored by this class due to its
    115         * deprecated status, it doesn't do any actual harm.
    116         *
    117         * @deprecated The <code>debug</code> static property is no longer used
    118         */
    119        private static int debug = 0;
    120
    121        /**
    122         * The <code>debug</code> static property is no longer used
    123         * @return debug property
    124         * @deprecated The <code>debug</code> static property is no longer used
    125         */
    126        public static int getDebug() {
    127            return (debug);
    128        }
    129
    130        /**
    131         * The <code>debug</code> static property is no longer used
    132         * @param newDebug debug property
    133         * @deprecated The <code>debug</code> static property is no longer used
    134         */
    135        public static void setDebug(int newDebug) {
    136            debug = newDebug;
    137        }
    138
    139        // --------------------------------------------------------- Public Methods
    140
    141
    142        /**
    143         * Clear any cached property descriptors information for all classes
    144         * loaded by any class loaders.  This is useful in cases where class
    145         * loaders are thrown away to implement class reloading.
    146         *
    147         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    148         *
    149         * @see PropertyUtilsBean#clearDescriptors
    150         */
    151        public static void clearDescriptors() {
    152
    153            PropertyUtilsBean.getInstance().clearDescriptors();
    154
    155        }
    156
    157
    158        /**
    159         * <p>Copy property values from the "origin" bean to the "destination" bean
    160         * for all cases where the property names are the same (even though the
    161         * actual getter and setter methods might have been customized via
    162         * <code>BeanInfo</code> classes).</p>
    163         *
    164         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    165         *
    166         * @param dest Destination bean whose properties are modified
    167         * @param orig Origin bean whose properties are retrieved
    168         *
    169         * @exception IllegalAccessException if the caller does not have
    170         *  access to the property accessor method
    171         * @exception IllegalArgumentException if the <code>dest</code> or
    172         *  <code>orig</code> argument is null
    173         * @exception InvocationTargetException if the property accessor method
    174         *  throws an exception
    175         * @exception NoSuchMethodException if an accessor method for this
    176         *  propety cannot be found
    177         * @see PropertyUtilsBean#copyProperties
    178         */
    179        public static void copyProperties(Object dest, Object orig)
    180                throws IllegalAccessException, InvocationTargetException,
    181                NoSuchMethodException {
    182
    183            PropertyUtilsBean.getInstance().copyProperties(dest, orig);
    184        }
    185
    186
    187        /**
    188         * <p>Return the entire set of properties for which the specified bean
    189         * provides a read method.</p>
    190         *
    191         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    192         *
    193         * @param bean Bean whose properties are to be extracted
    194         * @return The set of properties for the bean
    195         *
    196         * @exception IllegalAccessException if the caller does not have
    197         *  access to the property accessor method
    198         * @exception IllegalArgumentException if <code>bean</code> is null
    199         * @exception InvocationTargetException if the property accessor method
    200         *  throws an exception
    201         * @exception NoSuchMethodException if an accessor method for this
    202         *  propety cannot be found
    203         * @see PropertyUtilsBean#describe
    204         */
    205        public static Map describe(Object bean)
    206                throws IllegalAccessException, InvocationTargetException,
    207                NoSuchMethodException {
    208
    209            return (PropertyUtilsBean.getInstance().describe(bean));
    210
    211        }
    212
    213
    214        /**
    215         * <p>Return the value of the specified indexed property of the specified
    216         * bean, with no type conversions.</p>
    217         *
    218         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    219         *
    220         * @param bean Bean whose property is to be extracted
    221         * @param name <code>propertyname[index]</code> of the property value
    222         *  to be extracted
    223         * @return the indexed property value
    224         *
    225         * @exception IndexOutOfBoundsException if the specified index
    226         *  is outside the valid range for the underlying property
    227         * @exception IllegalAccessException if the caller does not have
    228         *  access to the property accessor method
    229         * @exception IllegalArgumentException if <code>bean</code> or
    230         *  <code>name</code> is null
    231         * @exception InvocationTargetException if the property accessor method
    232         *  throws an exception
    233         * @exception NoSuchMethodException if an accessor method for this
    234         *  propety cannot be found
    235         * @see PropertyUtilsBean#getIndexedProperty(Object,String)
    236         */
    237        public static Object getIndexedProperty(Object bean, String name)
    238                throws IllegalAccessException, InvocationTargetException,
    239                NoSuchMethodException {
    240
    241            return (PropertyUtilsBean.getInstance().getIndexedProperty(bean, name));
    242
    243        }
    244
    245
    246        /**
    247         * <p>Return the value of the specified indexed property of the specified
    248         * bean, with no type conversions.</p>
    249         *
    250         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    251         *
    252         * @param bean Bean whose property is to be extracted
    253         * @param name Simple property name of the property value to be extracted
    254         * @param index Index of the property value to be extracted
    255         * @return the indexed property value
    256         *
    257         * @exception IndexOutOfBoundsException if the specified index
    258         *  is outside the valid range for the underlying property
    259         * @exception IllegalAccessException if the caller does not have
    260         *  access to the property accessor method
    261         * @exception IllegalArgumentException if <code>bean</code> or
    262         *  <code>name</code> is null
    263         * @exception InvocationTargetException if the property accessor method
    264         *  throws an exception
    265         * @exception NoSuchMethodException if an accessor method for this
    266         *  propety cannot be found
    267         * @see PropertyUtilsBean#getIndexedProperty(Object,String, int)
    268         */
    269        public static Object getIndexedProperty(Object bean,
    270                                                String name, int index)
    271                throws IllegalAccessException, InvocationTargetException,
    272                NoSuchMethodException {
    273
    274            return (PropertyUtilsBean.getInstance().getIndexedProperty(bean, name, index));
    275        }
    276
    277
    278        /**
    279         * <p>Return the value of the specified mapped property of the
    280         * specified bean, with no type conversions.</p>
    281         *
    282         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    283         *
    284         * @param bean Bean whose property is to be extracted
    285         * @param name <code>propertyname(key)</code> of the property value
    286         *  to be extracted
    287         * @return the mapped property value
    288         *
    289         * @exception IllegalAccessException if the caller does not have
    290         *  access to the property accessor method
    291         * @exception InvocationTargetException if the property accessor method
    292         *  throws an exception
    293         * @exception NoSuchMethodException if an accessor method for this
    294         *  propety cannot be found
    295         * @see PropertyUtilsBean#getMappedProperty(Object,String)
    296         */
    297        public static Object getMappedProperty(Object bean, String name)
    298                throws IllegalAccessException, InvocationTargetException,
    299                NoSuchMethodException {
    300
    301            return (PropertyUtilsBean.getInstance().getMappedProperty(bean, name));
    302
    303        }
    304
    305
    306        /**
    307         * <p>Return the value of the specified mapped property of the specified
    308         * bean, with no type conversions.</p>
    309         *
    310         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    311         *
    312         * @param bean Bean whose property is to be extracted
    313         * @param name Mapped property name of the property value to be extracted
    314         * @param key Key of the property value to be extracted
    315         * @return the mapped property value
    316         *
    317         * @exception IllegalAccessException if the caller does not have
    318         *  access to the property accessor method
    319         * @exception InvocationTargetException if the property accessor method
    320         *  throws an exception
    321         * @exception NoSuchMethodException if an accessor method for this
    322         *  propety cannot be found
    323         * @see PropertyUtilsBean#getMappedProperty(Object,String, String)
    324         */
    325        public static Object getMappedProperty(Object bean,
    326                                               String name, String key)
    327                throws IllegalAccessException, InvocationTargetException,
    328                NoSuchMethodException {
    329
    330            return PropertyUtilsBean.getInstance().getMappedProperty(bean, name, key);
    331
    332        }
    333
    334
    335        /**
    336         * <p>Return the mapped property descriptors for this bean class.</p>
    337         *
    338         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    339         *
    340         * @param beanClass Bean class to be introspected
    341         * @return the mapped property descriptors
    342         * @see PropertyUtilsBean#getMappedPropertyDescriptors(Class)
    343         * @deprecated This method should not be exposed
    344         */
    345        public static FastHashMap getMappedPropertyDescriptors(Class beanClass) {
    346
    347            return PropertyUtilsBean.getInstance().getMappedPropertyDescriptors(beanClass);
    348
    349        }
    350
    351
    352        /**
    353         * <p>Return the mapped property descriptors for this bean.</p>
    354         *
    355         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    356         *
    357         * @param bean Bean to be introspected
    358         * @return the mapped property descriptors
    359         * @see PropertyUtilsBean#getMappedPropertyDescriptors(Object)
    360         * @deprecated This method should not be exposed
    361         */
    362        public static FastHashMap getMappedPropertyDescriptors(Object bean) {
    363
    364            return PropertyUtilsBean.getInstance().getMappedPropertyDescriptors(bean);
    365
    366        }
    367
    368
    369        /**
    370         * <p>Return the value of the (possibly nested) property of the specified
    371         * name, for the specified bean, with no type conversions.</p>
    372         *
    373         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    374         *
    375         * @param bean Bean whose property is to be extracted
    376         * @param name Possibly nested name of the property to be extracted
    377         * @return the nested property value
    378         *
    379         * @exception IllegalAccessException if the caller does not have
    380         *  access to the property accessor method
    381         * @exception IllegalArgumentException if <code>bean</code> or
    382         *  <code>name</code> is null
    383         * @exception NestedNullException if a nested reference to a
    384         *  property returns null
    385         * @exception InvocationTargetException
    386         * if the property accessor method throws an exception
    387         * @exception NoSuchMethodException if an accessor method for this
    388         *  propety cannot be found
    389         * @see PropertyUtilsBean#getNestedProperty
    390         */
    391        public static Object getNestedProperty(Object bean, String name)
    392                throws IllegalAccessException, InvocationTargetException,
    393                NoSuchMethodException {
    394
    395            return PropertyUtilsBean.getInstance().getNestedProperty(bean, name);
    396
    397        }
    398
    399
    400        /**
    401         * <p>Return the value of the specified property of the specified bean,
    402         * no matter which property reference format is used, with no
    403         * type conversions.</p>
    404         *
    405         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    406         *
    407         * @param bean Bean whose property is to be extracted
    408         * @param name Possibly indexed and/or nested name of the property
    409         *  to be extracted
    410         * @return the property value
    411         *
    412         * @exception IllegalAccessException if the caller does not have
    413         *  access to the property accessor method
    414         * @exception IllegalArgumentException if <code>bean</code> or
    415         *  <code>name</code> is null
    416         * @exception InvocationTargetException if the property accessor method
    417         *  throws an exception
    418         * @exception NoSuchMethodException if an accessor method for this
    419         *  propety cannot be found
    420         * @see PropertyUtilsBean#getProperty
    421         */
    422        public static Object getProperty(Object bean, String name)
    423                throws IllegalAccessException, InvocationTargetException,
    424                NoSuchMethodException {
    425
    426            return (PropertyUtilsBean.getInstance().getProperty(bean, name));
    427
    428        }
    429
    430
    431        /**
    432         * <p>Retrieve the property descriptor for the specified property of the
    433         * specified bean, or return <code>null</code> if there is no such
    434         * descriptor.</p>
    435         *
    436         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    437         *
    438         * @param bean Bean for which a property descriptor is requested
    439         * @param name Possibly indexed and/or nested name of the property for
    440         *  which a property descriptor is requested
    441         * @return the property descriptor
    442         *
    443         * @exception IllegalAccessException if the caller does not have
    444         *  access to the property accessor method
    445         * @exception IllegalArgumentException if <code>bean</code> or
    446         *  <code>name</code> is null
    447         * @exception IllegalArgumentException if a nested reference to a
    448         *  property returns null
    449         * @exception InvocationTargetException if the property accessor method
    450         *  throws an exception
    451         * @exception NoSuchMethodException if an accessor method for this
    452         *  propety cannot be found
    453         * @see PropertyUtilsBean#getPropertyDescriptor
    454         */
    455        public static PropertyDescriptor getPropertyDescriptor(Object bean,
    456                                                               String name)
    457                throws IllegalAccessException, InvocationTargetException,
    458                NoSuchMethodException {
    459
    460            return PropertyUtilsBean.getInstance().getPropertyDescriptor(bean, name);
    461
    462        }
    463
    464
    465        /**
    466         * <p>Retrieve the property descriptors for the specified class,
    467         * introspecting and caching them the first time a particular bean class
    468         * is encountered.</p>
    469         *
    470         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    471         *
    472         * @param beanClass Bean class for which property descriptors are requested
    473         * @return the property descriptors
    474         * @exception IllegalArgumentException if <code>beanClass</code> is null
    475         * @see PropertyUtilsBean#getPropertyDescriptors(Class)
    476         */
    477        public static PropertyDescriptor[]
    478                getPropertyDescriptors(Class beanClass) {
    479
    480            return PropertyUtilsBean.getInstance().getPropertyDescriptors(beanClass);
    481
    482        }
    483
    484
    485        /**
    486         * <p>Retrieve the property descriptors for the specified bean,
    487         * introspecting and caching them the first time a particular bean class
    488         * is encountered.</p>
    489         *
    490         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    491         *
    492         * @param bean Bean for which property descriptors are requested
    493         * @return the property descriptors
    494         * @exception IllegalArgumentException if <code>bean</code> is null
    495         * @see PropertyUtilsBean#getPropertyDescriptors(Object)
    496         */
    497        public static PropertyDescriptor[] getPropertyDescriptors(Object bean) {
    498
    499            return PropertyUtilsBean.getInstance().getPropertyDescriptors(bean);
    500
    501        }
    502
    503
    504        /**
    505         * <p>Return the Java Class repesenting the property editor class that has
    506         * been registered for this property (if any).</p>
    507         *
    508         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    509         *
    510         * @param bean Bean for which a property descriptor is requested
    511         * @param name Possibly indexed and/or nested name of the property for
    512         *  which a property descriptor is requested
    513         * @return the property editor class
    514         *
    515         * @exception IllegalAccessException if the caller does not have
    516         *  access to the property accessor method
    517         * @exception IllegalArgumentException if <code>bean</code> or
    518         *  <code>name</code> is null
    519         * @exception IllegalArgumentException if a nested reference to a
    520         *  property returns null
    521         * @exception InvocationTargetException if the property accessor method
    522         *  throws an exception
    523         * @exception NoSuchMethodException if an accessor method for this
    524         *  propety cannot be found
    525         * @see PropertyUtilsBean#getPropertyEditorClass(Object,String)
    526         */
    527        public static Class getPropertyEditorClass(Object bean, String name)
    528                throws IllegalAccessException, InvocationTargetException,
    529                NoSuchMethodException {
    530
    531            return PropertyUtilsBean.getInstance().getPropertyEditorClass(bean, name);
    532
    533        }
    534
    535
    536        /**
    537         * <p>Return the Java Class representing the property type of the specified
    538         * property, or <code>null</code> if there is no such property for the
    539         * specified bean.</p>
    540         *
    541         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    542         *
    543         * @param bean Bean for which a property descriptor is requested
    544         * @param name Possibly indexed and/or nested name of the property for
    545         *  which a property descriptor is requested
    546         * @return The property type
    547         *
    548         * @exception IllegalAccessException if the caller does not have
    549         *  access to the property accessor method
    550         * @exception IllegalArgumentException if <code>bean</code> or
    551         *  <code>name</code> is null
    552         * @exception IllegalArgumentException if a nested reference to a
    553         *  property returns null
    554         * @exception InvocationTargetException if the property accessor method
    555         *  throws an exception
    556         * @exception NoSuchMethodException if an accessor method for this
    557         *  propety cannot be found
    558         * @see PropertyUtilsBean#getPropertyType(Object, String)
    559         */
    560        public static Class getPropertyType(Object bean, String name)
    561                throws IllegalAccessException, InvocationTargetException,
    562                NoSuchMethodException {
    563
    564            return PropertyUtilsBean.getInstance().getPropertyType(bean, name);
    565        }
    566
    567
    568        /**
    569         * <p>Return an accessible property getter method for this property,
    570         * if there is one; otherwise return <code>null</code>.</p>
    571         *
    572         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    573         *
    574         * @param descriptor Property descriptor to return a getter for
    575         * @return The read method
    576         * @see PropertyUtilsBean#getReadMethod(PropertyDescriptor)
    577         */
    578        public static Method getReadMethod(PropertyDescriptor descriptor) {
    579
    580            return (PropertyUtilsBean.getInstance().getReadMethod(descriptor));
    581
    582        }
    583
    584
    585        /**
    586         * <p>Return the value of the specified simple property of the specified
    587         * bean, with no type conversions.</p>
    588         *
    589         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    590         *
    591         * @param bean Bean whose property is to be extracted
    592         * @param name Name of the property to be extracted
    593         * @return The property value
    594         *
    595         * @exception IllegalAccessException if the caller does not have
    596         *  access to the property accessor method
    597         * @exception IllegalArgumentException if <code>bean</code> or
    598         *  <code>name</code> is null
    599         * @exception IllegalArgumentException if the property name
    600         *  is nested or indexed
    601         * @exception InvocationTargetException if the property accessor method
    602         *  throws an exception
    603         * @exception NoSuchMethodException if an accessor method for this
    604         *  propety cannot be found
    605         * @see PropertyUtilsBean#getSimpleProperty
    606         */
    607        public static Object getSimpleProperty(Object bean, String name)
    608                throws IllegalAccessException, InvocationTargetException,
    609                NoSuchMethodException {
    610
    611            return PropertyUtilsBean.getInstance().getSimpleProperty(bean, name);
    612
    613        }
    614
    615
    616        /**
    617         * <p>Return an accessible property setter method for this property,
    618         * if there is one; otherwise return <code>null</code>.</p>
    619         *
    620         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    621         *
    622         * @param descriptor Property descriptor to return a setter for
    623         * @return The write method
    624         * @see PropertyUtilsBean#getWriteMethod(PropertyDescriptor)
    625         */
    626        public static Method getWriteMethod(PropertyDescriptor descriptor) {
    627
    628            return PropertyUtilsBean.getInstance().getWriteMethod(descriptor);
    629
    630        }
    631
    632
    633        /**
    634         * <p>Return <code>true</code> if the specified property name identifies
    635         * a readable property on the specified bean; otherwise, return
    636         * <code>false</code>.</p>
    637         *
    638         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    639         *
    640         * @param bean Bean to be examined (may be a {@link DynaBean}
    641         * @param name Property name to be evaluated
    642         * @return <code>true</code> if the property is readable,
    643         * otherwise <code>false</code>
    644         *
    645         * @exception IllegalArgumentException if <code>bean</code>
    646         *  or <code>name</code> is <code>null</code>
    647         * @see PropertyUtilsBean#isReadable
    648         * @since BeanUtils 1.6
    649         */
    650        public static boolean isReadable(Object bean, String name) {
    651
    652            return PropertyUtilsBean.getInstance().isReadable(bean, name);
    653        }
    654
    655
    656        /**
    657         * <p>Return <code>true</code> if the specified property name identifies
    658         * a writeable property on the specified bean; otherwise, return
    659         * <code>false</code>.</p>
    660         *
    661         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    662         *
    663         * @param bean Bean to be examined (may be a {@link DynaBean}
    664         * @param name Property name to be evaluated
    665         * @return <code>true</code> if the property is writeable,
    666         * otherwise <code>false</code>
    667         *
    668         * @exception IllegalArgumentException if <code>bean</code>
    669         *  or <code>name</code> is <code>null</code>
    670         * @see PropertyUtilsBean#isWriteable
    671         * @since BeanUtils 1.6
    672         */
    673        public static boolean isWriteable(Object bean, String name) {
    674
    675            return PropertyUtilsBean.getInstance().isWriteable(bean, name);
    676        }
    677
    678
    679        /**
    680         * <p>Sets the value of the specified indexed property of the specified
    681         * bean, with no type conversions.</p>
    682         *
    683         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    684         *
    685         * @param bean Bean whose property is to be modified
    686         * @param name <code>propertyname[index]</code> of the property value
    687         *  to be modified
    688         * @param value Value to which the specified property element
    689         *  should be set
    690         *
    691         * @exception IndexOutOfBoundsException if the specified index
    692         *  is outside the valid range for the underlying property
    693         * @exception IllegalAccessException if the caller does not have
    694         *  access to the property accessor method
    695         * @exception IllegalArgumentException if <code>bean</code> or
    696         *  <code>name</code> is null
    697         * @exception InvocationTargetException if the property accessor method
    698         *  throws an exception
    699         * @exception NoSuchMethodException if an accessor method for this
    700         *  propety cannot be found
    701         * @see PropertyUtilsBean#setIndexedProperty(Object, String, Object)
    702         */
    703        public static void setIndexedProperty(Object bean, String name,
    704                                              Object value)
    705                throws IllegalAccessException, InvocationTargetException,
    706                NoSuchMethodException {
    707
    708            PropertyUtilsBean.getInstance().setIndexedProperty(bean, name, value);
    709
    710        }
    711
    712
    713        /**
    714         * <p>Sets the value of the specified indexed property of the specified
    715         * bean, with no type conversions.</p>
    716         *
    717         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    718         *
    719         * @param bean Bean whose property is to be set
    720         * @param name Simple property name of the property value to be set
    721         * @param index Index of the property value to be set
    722         * @param value Value to which the indexed property element is to be set
    723         *
    724         * @exception IndexOutOfBoundsException if the specified index
    725         *  is outside the valid range for the underlying property
    726         * @exception IllegalAccessException if the caller does not have
    727         *  access to the property accessor method
    728         * @exception IllegalArgumentException if <code>bean</code> or
    729         *  <code>name</code> is null
    730         * @exception InvocationTargetException if the property accessor method
    731         *  throws an exception
    732         * @exception NoSuchMethodException if an accessor method for this
    733         *  propety cannot be found
    734         * @see PropertyUtilsBean#setIndexedProperty(Object, String, Object)
    735         */
    736        public static void setIndexedProperty(Object bean, String name,
    737                                              int index, Object value)
    738                throws IllegalAccessException, InvocationTargetException,
    739                NoSuchMethodException {
    740
    741            PropertyUtilsBean.getInstance().setIndexedProperty(bean, name, index, value);
    742        }
    743
    744
    745        /**
    746         * <p>Sets the value of the specified mapped property of the
    747         * specified bean, with no type conversions.</p>
    748         *
    749         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    750         *
    751         * @param bean Bean whose property is to be set
    752         * @param name <code>propertyname(key)</code> of the property value
    753         *  to be set
    754         * @param value The property value to be set
    755         *
    756         * @exception IllegalAccessException if the caller does not have
    757         *  access to the property accessor method
    758         * @exception InvocationTargetException if the property accessor method
    759         *  throws an exception
    760         * @exception NoSuchMethodException if an accessor method for this
    761         *  propety cannot be found
    762         * @see PropertyUtilsBean#setMappedProperty(Object, String, Object)
    763         */
    764        public static void setMappedProperty(Object bean, String name,
    765                                             Object value)
    766                throws IllegalAccessException, InvocationTargetException,
    767                NoSuchMethodException {
    768
    769            PropertyUtilsBean.getInstance().setMappedProperty(bean, name, value);
    770        }
    771
    772
    773        /**
    774         * <p>Sets the value of the specified mapped property of the specified
    775         * bean, with no type conversions.</p>
    776         *
    777         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    778         *
    779         * @param bean Bean whose property is to be set
    780         * @param name Mapped property name of the property value to be set
    781         * @param key Key of the property value to be set
    782         * @param value The property value to be set
    783         *
    784         * @exception IllegalAccessException if the caller does not have
    785         *  access to the property accessor method
    786         * @exception InvocationTargetException if the property accessor method
    787         *  throws an exception
    788         * @exception NoSuchMethodException if an accessor method for this
    789         *  propety cannot be found
    790         * @see PropertyUtilsBean#setMappedProperty(Object, String, String, Object)
    791         */
    792        public static void setMappedProperty(Object bean, String name,
    793                                             String key, Object value)
    794                throws IllegalAccessException, InvocationTargetException,
    795                NoSuchMethodException {
    796
    797            PropertyUtilsBean.getInstance().setMappedProperty(bean, name, key, value);
    798        }
    799
    800
    801        /**
    802         * <p>Sets the value of the (possibly nested) property of the specified
    803         * name, for the specified bean, with no type conversions.</p>
    804         *
    805         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    806         *
    807         * @param bean Bean whose property is to be modified
    808         * @param name Possibly nested name of the property to be modified
    809         * @param value Value to which the property is to be set
    810         *
    811         * @exception IllegalAccessException if the caller does not have
    812         *  access to the property accessor method
    813         * @exception IllegalArgumentException if <code>bean</code> or
    814         *  <code>name</code> is null
    815         * @exception IllegalArgumentException if a nested reference to a
    816         *  property returns null
    817         * @exception InvocationTargetException if the property accessor method
    818         *  throws an exception
    819         * @exception NoSuchMethodException if an accessor method for this
    820         *  propety cannot be found
    821         * @see PropertyUtilsBean#setNestedProperty
    822         */
    823        public static void setNestedProperty(Object bean,
    824                                             String name, Object value)
    825                throws IllegalAccessException, InvocationTargetException,
    826                NoSuchMethodException {
    827
    828            PropertyUtilsBean.getInstance().setNestedProperty(bean, name, value);
    829        }
    830
    831
    832        /**
    833         * <p>Set the value of the specified property of the specified bean,
    834         * no matter which property reference format is used, with no
    835         * type conversions.</p>
    836         *
    837         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    838         *
    839         * @param bean Bean whose property is to be modified
    840         * @param name Possibly indexed and/or nested name of the property
    841         *  to be modified
    842         * @param value Value to which this property is to be set
    843         *
    844         * @exception IllegalAccessException if the caller does not have
    845         *  access to the property accessor method
    846         * @exception IllegalArgumentException if <code>bean</code> or
    847         *  <code>name</code> is null
    848         * @exception InvocationTargetException if the property accessor method
    849         *  throws an exception
    850         * @exception NoSuchMethodException if an accessor method for this
    851         *  propety cannot be found
    852         * @see PropertyUtilsBean#setProperty
    853         */
    854        public static void setProperty(Object bean, String name, Object value)
    855                throws IllegalAccessException, InvocationTargetException,
    856                NoSuchMethodException {
    857
    858            PropertyUtilsBean.getInstance().setProperty(bean, name, value);
    859
    860        }
    861
    862
    863        /**
    864         * <p>Set the value of the specified simple property of the specified bean,
    865         * with no type conversions.</p>
    866         *
    867         * <p>For more details see <code>PropertyUtilsBean</code>.</p>
    868         *
    869         * @param bean Bean whose property is to be modified
    870         * @param name Name of the property to be modified
    871         * @param value Value to which the property should be set
    872         *
    873         * @exception IllegalAccessException if the caller does not have
    874         *  access to the property accessor method
    875         * @exception IllegalArgumentException if <code>bean</code> or
    876         *  <code>name</code> is null
    877         * @exception IllegalArgumentException if the property name is
    878         *  nested or indexed
    879         * @exception InvocationTargetException if the property accessor method
    880         *  throws an exception
    881         * @exception NoSuchMethodException if an accessor method for this
    882         *  propety cannot be found
    883         * @see PropertyUtilsBean#setSimpleProperty
    884         */
    885        public static void setSimpleProperty(Object bean,
    886                                             String name, Object value)
    887                throws IllegalAccessException, InvocationTargetException,
    888                NoSuchMethodException {
    889
    890            PropertyUtilsBean.getInstance().setSimpleProperty(bean, name, value);
    891        }
    892
    893
    894    }