提供静态方法访问单例对象中的方法

 
  1. PropertyUtils  就是此列
  2. /*
  3.  * Licensed to the Apache Software Foundation (ASF) under one or more
  4.  * contributor license agreements.  See the NOTICE file distributed with
  5.  * this work for additional information regarding copyright ownership.
  6.  * The ASF licenses this file to You under the Apache License, Version 2.0
  7.  * (the "License"); you may not use this file except in compliance with
  8.  * the License.  You may obtain a copy of the License at
  9.  *
  10.  *      http://www.apache.org/licenses/LICENSE-2.0
  11.  *
  12.  * Unless required by applicable law or agreed to in writing, software
  13.  * distributed under the License is distributed on an "AS IS" BASIS,
  14.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15.  * See the License for the specific language governing permissions and
  16.  * limitations under the License.
  17.  */
  18. package org.apache.commons.beanutils;
  19. import java.beans.PropertyDescriptor;
  20. import java.lang.reflect.InvocationTargetException;
  21. import java.lang.reflect.Method;
  22. import java.util.Map;
  23. import org.apache.commons.collections.FastHashMap;
  24. /**
  25.  * <p>Utility methods for using Java Reflection APIs to facilitate generic
  26.  * property getter and setter operations on Java objects.</p>
  27.  *
  28.  * <p>The implementations for these methods are provided by <code>PropertyUtilsBean</code>.
  29.  * For more details see {@link PropertyUtilsBean}.</p>
  30.  *
  31.  * @author Craig R. McClanahan
  32.  * @author Ralph Schaer
  33.  * @author Chris Audley
  34.  * @author Rey Francois
  35.  * @author Gregor Rayman
  36.  * @author Jan Sorensen
  37.  * @author Scott Sanders
  38.  * @version $Revision: 644137 $ $Date: 2008-04-03 03:30:23 +0100 (Thu, 03 Apr 2008) $
  39.  * @see PropertyUtilsBean
  40.  * @see org.apache.commons.beanutils.expression.Resolver
  41.  */
  42. public class 
  43. {
  44.     // ----------------------------------------------------- Manifest Constants
  45.     /**
  46.      * The delimiter that preceeds the zero-relative subscript for an
  47.      * indexed reference.
  48.      *
  49.      * @deprecated The notation used for property name expressions is now
  50.      * dependant on the {@link org.apache.commons.beanutils.expression.Resolver}
  51.      * implementation being used.
  52.      */
  53.     public static final char INDEXED_DELIM = '[';
  54.     /**
  55.      * The delimiter that follows the zero-relative subscript for an
  56.      * indexed reference.
  57.      *
  58.      * @deprecated The notation used for property name expressions is now
  59.      * dependant on the {@link org.apache.commons.beanutils.expression.Resolver}
  60.      * implementation being used.
  61.      */
  62.     public static final char INDEXED_DELIM2 = ']';
  63.     /**
  64.      * The delimiter that preceeds the key of a mapped property.
  65.      *
  66.      * @deprecated The notation used for property name expressions is now
  67.      * dependant on the {@link org.apache.commons.beanutils.expression.Resolver}
  68.      * implementation being used.
  69.      */
  70.     public static final char MAPPED_DELIM = '(';
  71.     /**
  72.      * The delimiter that follows the key of a mapped property.
  73.      *
  74.      * @deprecated The notation used for property name expressions is now
  75.      * dependant on the {@link org.apache.commons.beanutils.expression.Resolver}
  76.      * implementation being used.
  77.      */
  78.     public static final char MAPPED_DELIM2 = ')';
  79.     /**
  80.      * The delimiter that separates the components of a nested reference.
  81.      *
  82.      * @deprecated The notation used for property name expressions is now
  83.      * dependant on the {@link org.apache.commons.beanutils.expression.Resolver}
  84.      * implementation being used.
  85.      */
  86.     public static final char NESTED_DELIM = '.';
  87.     // ------------------------------------------------------- Static Variables
  88.     /**
  89.      * The debugging detail level for this component.
  90.      * 
  91.      * Note that this static variable will have unexpected side-effects if
  92.      * this class is deployed in a shared classloader within a container.
  93.      * However as it is actually completely ignored by this class due to its
  94.      * deprecated status, it doesn't do any actual harm.
  95.      *
  96.      * @deprecated The <code>debug</code> static property is no longer used
  97.      */
  98.     private static int debug = 0;
  99.     /**
  100.      * The <code>debug</code> static property is no longer used
  101.      * @return debug property
  102.      * @deprecated The <code>debug</code> static property is no longer used
  103.      */
  104.     public static int getDebug() {
  105.         return (debug);
  106.     }
  107.     /**
  108.      * The <code>debug</code> static property is no longer used
  109.      * @param newDebug debug property
  110.      * @deprecated The <code>debug</code> static property is no longer used
  111.      */
  112.     public static void setDebug(int newDebug) {
  113.         debug = newDebug;
  114.     }
  115.     // --------------------------------------------------------- Public Methods
  116.     /**
  117.      * Clear any cached property descriptors information for all classes
  118.      * loaded by any class loaders.  This is useful in cases where class
  119.      * loaders are thrown away to implement class reloading.
  120.      *
  121.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  122.      *
  123.      * @see PropertyUtilsBean#clearDescriptors  
  124.      */
  125.     public static void clearDescriptors() {
  126.         PropertyUtilsBean.getInstance().clearDescriptors();
  127.     }
  128.     /**
  129.      * <p>Copy property values from the "origin" bean to the "destination" bean
  130.      * for all cases where the property names are the same (even though the
  131.      * actual getter and setter methods might have been customized via
  132.      * <code>BeanInfo</code> classes).</p>
  133.      *
  134.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  135.      *
  136.      * @param dest Destination bean whose properties are modified
  137.      * @param orig Origin bean whose properties are retrieved
  138.      *
  139.      * @exception IllegalAccessException if the caller does not have
  140.      *  access to the property accessor method
  141.      * @exception IllegalArgumentException if the <code>dest</code> or
  142.      *  <code>orig</code> argument is null
  143.      * @exception InvocationTargetException if the property accessor method
  144.      *  throws an exception
  145.      * @exception NoSuchMethodException if an accessor method for this
  146.      *  propety cannot be found
  147.      * @see PropertyUtilsBean#copyProperties  
  148.      */
  149.     public static void copyProperties(Object dest, Object orig)
  150.             throws IllegalAccessException, InvocationTargetException,
  151.             NoSuchMethodException {
  152.         PropertyUtilsBean.getInstance().copyProperties(dest, orig);
  153.     }
  154.     /**
  155.      * <p>Return the entire set of properties for which the specified bean
  156.      * provides a read method.</p>
  157.      *
  158.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  159.      *
  160.      * @param bean Bean whose properties are to be extracted
  161.      * @return The set of properties for the bean
  162.      *
  163.      * @exception IllegalAccessException if the caller does not have
  164.      *  access to the property accessor method
  165.      * @exception IllegalArgumentException if <code>bean</code> is null
  166.      * @exception InvocationTargetException if the property accessor method
  167.      *  throws an exception
  168.      * @exception NoSuchMethodException if an accessor method for this
  169.      *  propety cannot be found
  170.      * @see PropertyUtilsBean#describe  
  171.      */
  172.     public static Map describe(Object bean)
  173.             throws IllegalAccessException, InvocationTargetException,
  174.             NoSuchMethodException {
  175.         return (PropertyUtilsBean.getInstance().describe(bean));
  176.     }
  177.     /**
  178.      * <p>Return the value of the specified indexed property of the specified
  179.      * bean, with no type conversions.</p>
  180.      *
  181.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  182.      *
  183.      * @param bean Bean whose property is to be extracted
  184.      * @param name <code>propertyname[index]</code> of the property value
  185.      *  to be extracted
  186.      * @return the indexed property value
  187.      *
  188.      * @exception IndexOutOfBoundsException if the specified index
  189.      *  is outside the valid range for the underlying property
  190.      * @exception IllegalAccessException if the caller does not have
  191.      *  access to the property accessor method
  192.      * @exception IllegalArgumentException if <code>bean</code> or
  193.      *  <code>name</code> is null
  194.      * @exception InvocationTargetException if the property accessor method
  195.      *  throws an exception
  196.      * @exception NoSuchMethodException if an accessor method for this
  197.      *  propety cannot be found
  198.      * @see PropertyUtilsBean#getIndexedProperty(Object,String)  
  199.      */
  200.     public static Object getIndexedProperty(Object bean, String name)
  201.             throws IllegalAccessException, InvocationTargetException,
  202.             NoSuchMethodException {
  203.         return (PropertyUtilsBean.getInstance().getIndexedProperty(bean, name));
  204.     }
  205.     /**
  206.      * <p>Return the value of the specified indexed property of the specified
  207.      * bean, with no type conversions.</p>
  208.      *
  209.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  210.      *
  211.      * @param bean Bean whose property is to be extracted
  212.      * @param name Simple property name of the property value to be extracted
  213.      * @param index Index of the property value to be extracted
  214.      * @return the indexed property value
  215.      *
  216.      * @exception IndexOutOfBoundsException if the specified index
  217.      *  is outside the valid range for the underlying property
  218.      * @exception IllegalAccessException if the caller does not have
  219.      *  access to the property accessor method
  220.      * @exception IllegalArgumentException if <code>bean</code> or
  221.      *  <code>name</code> is null
  222.      * @exception InvocationTargetException if the property accessor method
  223.      *  throws an exception
  224.      * @exception NoSuchMethodException if an accessor method for this
  225.      *  propety cannot be found
  226.      * @see PropertyUtilsBean#getIndexedProperty(Object,String, int)  
  227.      */
  228.     public static Object getIndexedProperty(Object bean,
  229.                                             String name, int index)
  230.             throws IllegalAccessException, InvocationTargetException,
  231.             NoSuchMethodException {
  232.         return (PropertyUtilsBean.getInstance().getIndexedProperty(bean, name, index));
  233.     }
  234.     /**
  235.      * <p>Return the value of the specified mapped property of the
  236.      * specified bean, with no type conversions.</p>
  237.      *
  238.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  239.      *
  240.      * @param bean Bean whose property is to be extracted
  241.      * @param name <code>propertyname(key)</code> of the property value
  242.      *  to be extracted
  243.      * @return the mapped property value
  244.      *
  245.      * @exception IllegalAccessException if the caller does not have
  246.      *  access to the property accessor method
  247.      * @exception InvocationTargetException if the property accessor method
  248.      *  throws an exception
  249.      * @exception NoSuchMethodException if an accessor method for this
  250.      *  propety cannot be found
  251.      * @see PropertyUtilsBean#getMappedProperty(Object,String)  
  252.      */
  253.     public static Object getMappedProperty(Object bean, String name)
  254.             throws IllegalAccessException, InvocationTargetException,
  255.             NoSuchMethodException {
  256.         return (PropertyUtilsBean.getInstance().getMappedProperty(bean, name));
  257.     }
  258.     /**
  259.      * <p>Return the value of the specified mapped property of the specified
  260.      * bean, with no type conversions.</p>
  261.      *
  262.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  263.      *
  264.      * @param bean Bean whose property is to be extracted
  265.      * @param name Mapped property name of the property value to be extracted
  266.      * @param key Key of the property value to be extracted
  267.      * @return the mapped property value
  268.      *
  269.      * @exception IllegalAccessException if the caller does not have
  270.      *  access to the property accessor method
  271.      * @exception InvocationTargetException if the property accessor method
  272.      *  throws an exception
  273.      * @exception NoSuchMethodException if an accessor method for this
  274.      *  propety cannot be found
  275.      * @see PropertyUtilsBean#getMappedProperty(Object,String, String)  
  276.      */
  277.     public static Object getMappedProperty(Object bean,
  278.                                            String name, String key)
  279.             throws IllegalAccessException, InvocationTargetException,
  280.             NoSuchMethodException {
  281.         return PropertyUtilsBean.getInstance().getMappedProperty(bean, name, key);
  282.     }
  283.     /**
  284.      * <p>Return the mapped property descriptors for this bean class.</p>
  285.      *
  286.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  287.      *
  288.      * @param beanClass Bean class to be introspected
  289.      * @return the mapped property descriptors
  290.      * @see PropertyUtilsBean#getMappedPropertyDescriptors(Class)
  291.      * @deprecated This method should not be exposed
  292.      */
  293.     public static FastHashMap getMappedPropertyDescriptors(Class beanClass) {
  294.         return PropertyUtilsBean.getInstance().getMappedPropertyDescriptors(beanClass);
  295.     }
  296.     /**
  297.      * <p>Return the mapped property descriptors for this bean.</p>
  298.      *
  299.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  300.      *
  301.      * @param bean Bean to be introspected
  302.      * @return the mapped property descriptors
  303.      * @see PropertyUtilsBean#getMappedPropertyDescriptors(Object)
  304.      * @deprecated This method should not be exposed
  305.      */
  306.     public static FastHashMap getMappedPropertyDescriptors(Object bean) {
  307.         return PropertyUtilsBean.getInstance().getMappedPropertyDescriptors(bean);
  308.     }
  309.     /**
  310.      * <p>Return the value of the (possibly nested) property of the specified
  311.      * name, for the specified bean, with no type conversions.</p>
  312.      *
  313.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  314.      *
  315.      * @param bean Bean whose property is to be extracted
  316.      * @param name Possibly nested name of the property to be extracted
  317.      * @return the nested property value
  318.      *
  319.      * @exception IllegalAccessException if the caller does not have
  320.      *  access to the property accessor method
  321.      * @exception IllegalArgumentException if <code>bean</code> or
  322.      *  <code>name</code> is null
  323.      * @exception NestedNullException if a nested reference to a
  324.      *  property returns null
  325.      * @exception InvocationTargetException 
  326.      * if the property accessor method throws an exception
  327.      * @exception NoSuchMethodException if an accessor method for this
  328.      *  propety cannot be found
  329.      * @see PropertyUtilsBean#getNestedProperty
  330.      */
  331.     public static Object getNestedProperty(Object bean, String name)
  332.             throws IllegalAccessException, InvocationTargetException,
  333.             NoSuchMethodException {
  334.         return PropertyUtilsBean.getInstance().getNestedProperty(bean, name);
  335.         
  336.     }
  337.     /**
  338.      * <p>Return the value of the specified property of the specified bean,
  339.      * no matter which property reference format is used, with no
  340.      * type conversions.</p>
  341.      *
  342.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  343.      *
  344.      * @param bean Bean whose property is to be extracted
  345.      * @param name Possibly indexed and/or nested name of the property
  346.      *  to be extracted
  347.      * @return the property value
  348.      *
  349.      * @exception IllegalAccessException if the caller does not have
  350.      *  access to the property accessor method
  351.      * @exception IllegalArgumentException if <code>bean</code> or
  352.      *  <code>name</code> is null
  353.      * @exception InvocationTargetException if the property accessor method
  354.      *  throws an exception
  355.      * @exception NoSuchMethodException if an accessor method for this
  356.      *  propety cannot be found
  357.      * @see PropertyUtilsBean#getProperty
  358.      */
  359.     public static Object getProperty(Object bean, String name)
  360.             throws IllegalAccessException, InvocationTargetException,
  361.             NoSuchMethodException {
  362.         return (PropertyUtilsBean.getInstance().getProperty(bean, name));
  363.     }
  364.     /**
  365.      * <p>Retrieve the property descriptor for the specified property of the
  366.      * specified bean, or return <code>null</code> if there is no such
  367.      * descriptor.</p>
  368.      *
  369.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  370.      *
  371.      * @param bean Bean for which a property descriptor is requested
  372.      * @param name Possibly indexed and/or nested name of the property for
  373.      *  which a property descriptor is requested
  374.      * @return the property descriptor
  375.      *
  376.      * @exception IllegalAccessException if the caller does not have
  377.      *  access to the property accessor method
  378.      * @exception IllegalArgumentException if <code>bean</code> or
  379.      *  <code>name</code> is null
  380.      * @exception IllegalArgumentException if a nested reference to a
  381.      *  property returns null
  382.      * @exception InvocationTargetException if the property accessor method
  383.      *  throws an exception
  384.      * @exception NoSuchMethodException if an accessor method for this
  385.      *  propety cannot be found
  386.      * @see PropertyUtilsBean#getPropertyDescriptor
  387.      */
  388.     public static PropertyDescriptor getPropertyDescriptor(Object bean,
  389.                                                            String name)
  390.             throws IllegalAccessException, InvocationTargetException,
  391.             NoSuchMethodException {
  392.         return PropertyUtilsBean.getInstance().getPropertyDescriptor(bean, name);
  393.     }
  394.     /**
  395.      * <p>Retrieve the property descriptors for the specified class,
  396.      * introspecting and caching them the first time a particular bean class
  397.      * is encountered.</p>
  398.      *
  399.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  400.      *
  401.      * @param beanClass Bean class for which property descriptors are requested
  402.      * @return the property descriptors
  403.      * @exception IllegalArgumentException if <code>beanClass</code> is null
  404.      * @see PropertyUtilsBean#getPropertyDescriptors(Class)
  405.      */
  406.     public static PropertyDescriptor[]
  407.             getPropertyDescriptors(Class beanClass) {
  408.         return PropertyUtilsBean.getInstance().getPropertyDescriptors(beanClass);
  409.     }
  410.     /**
  411.      * <p>Retrieve the property descriptors for the specified bean,
  412.      * introspecting and caching them the first time a particular bean class
  413.      * is encountered.</p>
  414.      *
  415.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  416.      *
  417.      * @param bean Bean for which property descriptors are requested
  418.      * @return the property descriptors
  419.      * @exception IllegalArgumentException if <code>bean</code> is null
  420.      * @see PropertyUtilsBean#getPropertyDescriptors(Object)
  421.      */
  422.     public static PropertyDescriptor[] getPropertyDescriptors(Object bean) {
  423.         return PropertyUtilsBean.getInstance().getPropertyDescriptors(bean);
  424.     }
  425.     /**
  426.      * <p>Return the Java Class repesenting the property editor class that has
  427.      * been registered for this property (if any).</p>
  428.      *
  429.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  430.      *
  431.      * @param bean Bean for which a property descriptor is requested
  432.      * @param name Possibly indexed and/or nested name of the property for
  433.      *  which a property descriptor is requested
  434.      * @return the property editor class
  435.      *
  436.      * @exception IllegalAccessException if the caller does not have
  437.      *  access to the property accessor method
  438.      * @exception IllegalArgumentException if <code>bean</code> or
  439.      *  <code>name</code> is null
  440.      * @exception IllegalArgumentException if a nested reference to a
  441.      *  property returns null
  442.      * @exception InvocationTargetException if the property accessor method
  443.      *  throws an exception
  444.      * @exception NoSuchMethodException if an accessor method for this
  445.      *  propety cannot be found
  446.      * @see PropertyUtilsBean#getPropertyEditorClass(Object,String)
  447.      */
  448.     public static Class getPropertyEditorClass(Object bean, String name)
  449.             throws IllegalAccessException, InvocationTargetException,
  450.             NoSuchMethodException {
  451.         return PropertyUtilsBean.getInstance().getPropertyEditorClass(bean, name);
  452.     }
  453.     /**
  454.      * <p>Return the Java Class representing the property type of the specified
  455.      * property, or <code>null</code> if there is no such property for the
  456.      * specified bean.</p>
  457.      *
  458.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  459.      *
  460.      * @param bean Bean for which a property descriptor is requested
  461.      * @param name Possibly indexed and/or nested name of the property for
  462.      *  which a property descriptor is requested
  463.      * @return The property type
  464.      *
  465.      * @exception IllegalAccessException if the caller does not have
  466.      *  access to the property accessor method
  467.      * @exception IllegalArgumentException if <code>bean</code> or
  468.      *  <code>name</code> is null
  469.      * @exception IllegalArgumentException if a nested reference to a
  470.      *  property returns null
  471.      * @exception InvocationTargetException if the property accessor method
  472.      *  throws an exception
  473.      * @exception NoSuchMethodException if an accessor method for this
  474.      *  propety cannot be found
  475.      * @see PropertyUtilsBean#getPropertyType(Object, String)
  476.      */
  477.     public static Class getPropertyType(Object bean, String name)
  478.             throws IllegalAccessException, InvocationTargetException,
  479.             NoSuchMethodException {
  480.         return PropertyUtilsBean.getInstance().getPropertyType(bean, name);
  481.     }
  482.     /**
  483.      * <p>Return an accessible property getter method for this property,
  484.      * if there is one; otherwise return <code>null</code>.</p>
  485.      *
  486.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  487.      *
  488.      * @param descriptor Property descriptor to return a getter for
  489.      * @return The read method
  490.      * @see PropertyUtilsBean#getReadMethod(PropertyDescriptor)
  491.      */
  492.     public static Method getReadMethod(PropertyDescriptor descriptor) {
  493.         return (PropertyUtilsBean.getInstance().getReadMethod(descriptor));
  494.     }
  495.     /**
  496.      * <p>Return the value of the specified simple property of the specified
  497.      * bean, with no type conversions.</p>
  498.      *
  499.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  500.      *
  501.      * @param bean Bean whose property is to be extracted
  502.      * @param name Name of the property to be extracted
  503.      * @return The property value
  504.      *
  505.      * @exception IllegalAccessException if the caller does not have
  506.      *  access to the property accessor method
  507.      * @exception IllegalArgumentException if <code>bean</code> or
  508.      *  <code>name</code> is null
  509.      * @exception IllegalArgumentException if the property name
  510.      *  is nested or indexed
  511.      * @exception InvocationTargetException if the property accessor method
  512.      *  throws an exception
  513.      * @exception NoSuchMethodException if an accessor method for this
  514.      *  propety cannot be found
  515.      * @see PropertyUtilsBean#getSimpleProperty
  516.      */
  517.     public static Object getSimpleProperty(Object bean, String name)
  518.             throws IllegalAccessException, InvocationTargetException,
  519.             NoSuchMethodException {
  520.         return PropertyUtilsBean.getInstance().getSimpleProperty(bean, name);
  521.         
  522.     }
  523.     /**
  524.      * <p>Return an accessible property setter method for this property,
  525.      * if there is one; otherwise return <code>null</code>.</p>
  526.      *
  527.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  528.      *
  529.      * @param descriptor Property descriptor to return a setter for
  530.      * @return The write method
  531.      * @see PropertyUtilsBean#getWriteMethod(PropertyDescriptor)
  532.      */
  533.     public static Method getWriteMethod(PropertyDescriptor descriptor) {
  534.         return PropertyUtilsBean.getInstance().getWriteMethod(descriptor);
  535.     }
  536.     /**
  537.      * <p>Return <code>true</code> if the specified property name identifies
  538.      * a readable property on the specified bean; otherwise, return
  539.      * <code>false</code>.</p>
  540.      *
  541.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  542.      *
  543.      * @param bean Bean to be examined (may be a {@link DynaBean}
  544.      * @param name Property name to be evaluated
  545.      * @return <code>true</code> if the property is readable,
  546.      * otherwise <code>false</code>
  547.      *
  548.      * @exception IllegalArgumentException if <code>bean</code>
  549.      *  or <code>name</code> is <code>null</code>
  550.      * @see PropertyUtilsBean#isReadable
  551.      * @since BeanUtils 1.6
  552.      */
  553.     public static boolean isReadable(Object bean, String name) {
  554.         return PropertyUtilsBean.getInstance().isReadable(bean, name);
  555.     }
  556.     /**
  557.      * <p>Return <code>true</code> if the specified property name identifies
  558.      * a writeable property on the specified bean; otherwise, return
  559.      * <code>false</code>.</p>
  560.      *
  561.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  562.      *
  563.      * @param bean Bean to be examined (may be a {@link DynaBean}
  564.      * @param name Property name to be evaluated
  565.      * @return <code>true</code> if the property is writeable,
  566.      * otherwise <code>false</code>
  567.      *
  568.      * @exception IllegalArgumentException if <code>bean</code>
  569.      *  or <code>name</code> is <code>null</code>
  570.      * @see PropertyUtilsBean#isWriteable
  571.      * @since BeanUtils 1.6
  572.      */
  573.     public static boolean isWriteable(Object bean, String name) {
  574.         return PropertyUtilsBean.getInstance().isWriteable(bean, name);
  575.     }
  576.     /**
  577.      * <p>Sets the value of the specified indexed property of the specified
  578.      * bean, with no type conversions.</p>
  579.      *
  580.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  581.      *
  582.      * @param bean Bean whose property is to be modified
  583.      * @param name <code>propertyname[index]</code> of the property value
  584.      *  to be modified
  585.      * @param value Value to which the specified property element
  586.      *  should be set
  587.      *
  588.      * @exception IndexOutOfBoundsException if the specified index
  589.      *  is outside the valid range for the underlying property
  590.      * @exception IllegalAccessException if the caller does not have
  591.      *  access to the property accessor method
  592.      * @exception IllegalArgumentException if <code>bean</code> or
  593.      *  <code>name</code> is null
  594.      * @exception InvocationTargetException if the property accessor method
  595.      *  throws an exception
  596.      * @exception NoSuchMethodException if an accessor method for this
  597.      *  propety cannot be found
  598.      * @see PropertyUtilsBean#setIndexedProperty(Object, String, Object)
  599.      */
  600.     public static void setIndexedProperty(Object bean, String name,
  601.                                           Object value)
  602.             throws IllegalAccessException, InvocationTargetException,
  603.             NoSuchMethodException {
  604.         PropertyUtilsBean.getInstance().setIndexedProperty(bean, name, value);
  605.     }
  606.     /**
  607.      * <p>Sets the value of the specified indexed property of the specified
  608.      * bean, with no type conversions.</p>
  609.      *
  610.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  611.      *
  612.      * @param bean Bean whose property is to be set
  613.      * @param name Simple property name of the property value to be set
  614.      * @param index Index of the property value to be set
  615.      * @param value Value to which the indexed property element is to be set
  616.      *
  617.      * @exception IndexOutOfBoundsException if the specified index
  618.      *  is outside the valid range for the underlying property
  619.      * @exception IllegalAccessException if the caller does not have
  620.      *  access to the property accessor method
  621.      * @exception IllegalArgumentException if <code>bean</code> or
  622.      *  <code>name</code> is null
  623.      * @exception InvocationTargetException if the property accessor method
  624.      *  throws an exception
  625.      * @exception NoSuchMethodException if an accessor method for this
  626.      *  propety cannot be found
  627.      * @see PropertyUtilsBean#setIndexedProperty(Object, String, Object)
  628.      */
  629.     public static void setIndexedProperty(Object bean, String name,
  630.                                           int index, Object value)
  631.             throws IllegalAccessException, InvocationTargetException,
  632.             NoSuchMethodException {
  633.         PropertyUtilsBean.getInstance().setIndexedProperty(bean, name, index, value);
  634.     }
  635.     /**
  636.      * <p>Sets the value of the specified mapped property of the
  637.      * specified bean, with no type conversions.</p>
  638.      *
  639.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  640.      *
  641.      * @param bean Bean whose property is to be set
  642.      * @param name <code>propertyname(key)</code> of the property value
  643.      *  to be set
  644.      * @param value The property value to be set
  645.      *
  646.      * @exception IllegalAccessException if the caller does not have
  647.      *  access to the property accessor method
  648.      * @exception InvocationTargetException if the property accessor method
  649.      *  throws an exception
  650.      * @exception NoSuchMethodException if an accessor method for this
  651.      *  propety cannot be found
  652.      * @see PropertyUtilsBean#setMappedProperty(Object, String, Object)
  653.      */
  654.     public static void setMappedProperty(Object bean, String name,
  655.                                          Object value)
  656.             throws IllegalAccessException, InvocationTargetException,
  657.             NoSuchMethodException {
  658.         PropertyUtilsBean.getInstance().setMappedProperty(bean, name, value);
  659.     }
  660.     /**
  661.      * <p>Sets the value of the specified mapped property of the specified
  662.      * bean, with no type conversions.</p>
  663.      *
  664.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  665.      *
  666.      * @param bean Bean whose property is to be set
  667.      * @param name Mapped property name of the property value to be set
  668.      * @param key Key of the property value to be set
  669.      * @param value The property value to be set
  670.      *
  671.      * @exception IllegalAccessException if the caller does not have
  672.      *  access to the property accessor method
  673.      * @exception InvocationTargetException if the property accessor method
  674.      *  throws an exception
  675.      * @exception NoSuchMethodException if an accessor method for this
  676.      *  propety cannot be found
  677.      * @see PropertyUtilsBean#setMappedProperty(Object, String, String, Object)
  678.      */
  679.     public static void setMappedProperty(Object bean, String name,
  680.                                          String key, Object value)
  681.             throws IllegalAccessException, InvocationTargetException,
  682.             NoSuchMethodException {
  683.         PropertyUtilsBean.getInstance().setMappedProperty(bean, name, key, value);
  684.     }
  685.     /**
  686.      * <p>Sets the value of the (possibly nested) property of the specified
  687.      * name, for the specified bean, with no type conversions.</p>
  688.      *
  689.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  690.      *
  691.      * @param bean Bean whose property is to be modified
  692.      * @param name Possibly nested name of the property to be modified
  693.      * @param value Value to which the property is to be set
  694.      *
  695.      * @exception IllegalAccessException if the caller does not have
  696.      *  access to the property accessor method
  697.      * @exception IllegalArgumentException if <code>bean</code> or
  698.      *  <code>name</code> is null
  699.      * @exception IllegalArgumentException if a nested reference to a
  700.      *  property returns null
  701.      * @exception InvocationTargetException if the property accessor method
  702.      *  throws an exception
  703.      * @exception NoSuchMethodException if an accessor method for this
  704.      *  propety cannot be found
  705.      * @see PropertyUtilsBean#setNestedProperty
  706.      */
  707.     public static void setNestedProperty(Object bean,
  708.                                          String name, Object value)
  709.             throws IllegalAccessException, InvocationTargetException,
  710.             NoSuchMethodException {
  711.         PropertyUtilsBean.getInstance().setNestedProperty(bean, name, value);
  712.     }
  713.     /**
  714.      * <p>Set the value of the specified property of the specified bean,
  715.      * no matter which property reference format is used, with no
  716.      * type conversions.</p>
  717.      *
  718.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  719.      *
  720.      * @param bean Bean whose property is to be modified
  721.      * @param name Possibly indexed and/or nested name of the property
  722.      *  to be modified
  723.      * @param value Value to which this property is to be set
  724.      *
  725.      * @exception IllegalAccessException if the caller does not have
  726.      *  access to the property accessor method
  727.      * @exception IllegalArgumentException if <code>bean</code> or
  728.      *  <code>name</code> is null
  729.      * @exception InvocationTargetException if the property accessor method
  730.      *  throws an exception
  731.      * @exception NoSuchMethodException if an accessor method for this
  732.      *  propety cannot be found
  733.      * @see PropertyUtilsBean#setProperty
  734.      */
  735.     public static void setProperty(Object bean, String name, Object value)
  736.             throws IllegalAccessException, InvocationTargetException,
  737.             NoSuchMethodException {
  738.         PropertyUtilsBean.getInstance().setProperty(bean, name, value);
  739.     }
  740.     /**
  741.      * <p>Set the value of the specified simple property of the specified bean,
  742.      * with no type conversions.</p>
  743.      *
  744.      * <p>For more details see <code>PropertyUtilsBean</code>.</p>
  745.      *
  746.      * @param bean Bean whose property is to be modified
  747.      * @param name Name of the property to be modified
  748.      * @param value Value to which the property should be set
  749.      *
  750.      * @exception IllegalAccessException if the caller does not have
  751.      *  access to the property accessor method
  752.      * @exception IllegalArgumentException if <code>bean</code> or
  753.      *  <code>name</code> is null
  754.      * @exception IllegalArgumentException if the property name is
  755.      *  nested or indexed
  756.      * @exception InvocationTargetException if the property accessor method
  757.      *  throws an exception
  758.      * @exception NoSuchMethodException if an accessor method for this
  759.      *  propety cannot be found
  760.      * @see PropertyUtilsBean#setSimpleProperty
  761.      */
  762.     public static void setSimpleProperty(Object bean,
  763.                                          String name, Object value)
  764.             throws IllegalAccessException, InvocationTargetException,
  765.             NoSuchMethodException {
  766.         PropertyUtilsBean.getInstance().setSimpleProperty(bean, name, value);
  767.     }
  768. }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

随风九天

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值