org.springframework.beans

## 类 BeanWrapperImpl

- java.lang.Object
- - org.springframework.beans.PropertyEditorRegistrySupport
  - - org.springframework.beans.TypeConverterSupport
    - - org.springframework.beans.AbstractPropertyAccessor
      - - org.springframework.beans.AbstractNestablePropertyAccessor
        - - org.springframework.beans.BeanWrapperImpl

- 所有已实现的接口:
    BeanWrapper, ConfigurablePropertyAccessor, PropertyAccessor, PropertyEditorRegistry, TypeConverter

      public class BeanWrapperImpl
      extends AbstractNestablePropertyAccessor
      implements BeanWrapper

  Default `BeanWrapper` implementation that should be sufficient for all typical use cases. Caches introspection results for efficiency.

  Note: Auto-registers default property editors from the `org.springframework.beans.propertyeditors` package, which apply in addition to the JDK's standard PropertyEditors. Applications can call the `PropertyEditorRegistrySupport.registerCustomEditor(Class, java.beans.PropertyEditor)` method to register an editor for a particular instance (i.e. they are not shared across the application). See the base class `PropertyEditorRegistrySupport` for details.

  NOTE: As of Spring 2.5, this is - for almost all purposes - an internal class. It is just public in order to allow for access from other framework packages. For standard application access purposes, use the `PropertyAccessorFactory.forBeanPropertyAccess(java.lang.Object)` factory method instead.

  从以下版本开始:
    15 April 2001
  作者:
    Rod Johnson, Juergen Hoeller, Rob Harrop, Stephane Nicoll
  另请参阅:
    `PropertyEditorRegistrySupport.registerCustomEditor(java.lang.Class<?>, java.beans.PropertyEditor)`, `AbstractPropertyAccessor.setPropertyValues(java.util.Map<?, ?>)`, `AbstractNestablePropertyAccessor.setPropertyValue(java.lang.String, java.lang.Object)`, `AbstractNestablePropertyAccessor.getPropertyValue(java.lang.String)`, `AbstractNestablePropertyAccessor.getPropertyType(java.lang.String)`, `BeanWrapper`, `PropertyEditorRegistrySupport`

- - ### 嵌套类概要

    - ### 从类继承的嵌套类/接口 org.springframework.beans.AbstractNestablePropertyAccessor

      `AbstractNestablePropertyAccessor.PropertyHandler, AbstractNestablePropertyAccessor.PropertyTokenHolder`

  - ### 字段概要

    - ### 从接口继承的字段 org.springframework.beans.PropertyAccessor

      `NESTED_PROPERTY_SEPARATOR, NESTED_PROPERTY_SEPARATOR_CHAR, PROPERTY_KEY_PREFIX, PROPERTY_KEY_PREFIX_CHAR, PROPERTY_KEY_SUFFIX, PROPERTY_KEY_SUFFIX_CHAR`

  - ### 构造器概要

    构造器
    构造器和说明
    `BeanWrapperImpl()` Create a new empty BeanWrapperImpl.
    `BeanWrapperImpl(boolean registerDefaultEditors)` Create a new empty BeanWrapperImpl.
    `BeanWrapperImpl(Class<?> clazz)` Create a new BeanWrapperImpl, wrapping a new instance of the specified class.
    `BeanWrapperImpl(Object object)` Create a new BeanWrapperImpl for the given object.
    `BeanWrapperImpl(Object object, String nestedPath, Object rootObject)` Create a new BeanWrapperImpl for the given object, registering a nested path that the object is in.

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `Object` | `convertForProperty(Object value, String propertyName)` Convert the given value for the specified property to the latter's type.
    `protected NotWritablePropertyException` | `createNotWritablePropertyException(String propertyName)` Create a `NotWritablePropertyException` for the specified property.
    `protected org.springframework.beans.BeanWrapperImpl.BeanPropertyHandler` | `getLocalPropertyHandler(String propertyName)` Return a `AbstractNestablePropertyAccessor.PropertyHandler` for the specified local `propertyName`.
    `PropertyDescriptor` | `getPropertyDescriptor(String propertyName)` Obtain the property descriptor for a specific property of the wrapped object.
    `PropertyDescriptor[]` | `getPropertyDescriptors()` Obtain the PropertyDescriptors for the wrapped object (as determined by standard JavaBeans introspection).
    `AccessControlContext` | `getSecurityContext()` Return the security context used during the invocation of the wrapped instance methods.
    `protected BeanWrapperImpl` | `newNestedPropertyAccessor(Object object, String nestedPath)` Create a new nested property accessor instance.
    `void` | `setBeanInstance(Object object)` Set a bean instance to hold, without any unwrapping of `Optional`.
    `protected void` | `setIntrospectionClass(Class<?> clazz)` Set the class to introspect.
    `void` | `setSecurityContext(AccessControlContext acc)` Set the security context used during the invocation of the wrapped instance methods.
    `void` | `setWrappedInstance(Object object, String nestedPath, Object rootObject)` Switch the target object, replacing the cached introspection results only if the class of the new object is different to that of the replaced object.

    - ### 从类继承的方法 org.springframework.beans.AbstractNestablePropertyAccessor

      `convertForProperty, getAutoGrowCollectionLimit, getFinalPath, getNestedPath, getPropertyAccessorForPropertyPath, getPropertyHandler, getPropertyType, getPropertyTypeDescriptor, getPropertyValue, getPropertyValue, getRootClass, getRootInstance, getWrappedClass, getWrappedInstance, isReadableProperty, isWritableProperty, setAutoGrowCollectionLimit, setPropertyValue, setPropertyValue, setPropertyValue, setWrappedInstance, toString`

    - ### 从类继承的方法 org.springframework.beans.AbstractPropertyAccessor

      `isAutoGrowNestedPaths, isExtractOldValueForEditor, setAutoGrowNestedPaths, setExtractOldValueForEditor, setPropertyValues, setPropertyValues, setPropertyValues, setPropertyValues`

    - ### 从类继承的方法 org.springframework.beans.TypeConverterSupport

      `convertIfNecessary, convertIfNecessary, convertIfNecessary`

    - ### 从类继承的方法 org.springframework.beans.PropertyEditorRegistrySupport

      `copyCustomEditorsTo, copyDefaultEditorsTo, findCustomEditor, getConversionService, getDefaultEditor, guessPropertyTypeFromEditors, hasCustomEditorForElement, overrideDefaultEditor, registerCustomEditor, registerCustomEditor, registerDefaultEditors, setConversionService, useConfigValueEditors`

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### 从接口继承的方法 org.springframework.beans.BeanWrapper

      `getAutoGrowCollectionLimit, getWrappedClass, getWrappedInstance, setAutoGrowCollectionLimit`

    - ### 从接口继承的方法 org.springframework.beans.ConfigurablePropertyAccessor

      `getConversionService, isAutoGrowNestedPaths, isExtractOldValueForEditor, setAutoGrowNestedPaths, setConversionService, setExtractOldValueForEditor`

    - ### 从接口继承的方法 org.springframework.beans.PropertyAccessor

      `getPropertyType, getPropertyTypeDescriptor, getPropertyValue, isReadableProperty, isWritableProperty, setPropertyValue, setPropertyValue, setPropertyValues, setPropertyValues, setPropertyValues, setPropertyValues`

    - ### 从接口继承的方法 org.springframework.beans.PropertyEditorRegistry

      `findCustomEditor, registerCustomEditor, registerCustomEditor`

    - ### 从接口继承的方法 org.springframework.beans.TypeConverter

      `convertIfNecessary, convertIfNecessary, convertIfNecessary`

- - ### 构造器详细资料

    - #### BeanWrapperImpl

          public BeanWrapperImpl()

      Create a new empty BeanWrapperImpl. Wrapped instance needs to be set afterwards. Registers default editors.
      另请参阅:
        `setWrappedInstance(java.lang.Object, java.lang.String, java.lang.Object)`

    - #### BeanWrapperImpl

          public BeanWrapperImpl(boolean registerDefaultEditors)

      Create a new empty BeanWrapperImpl. Wrapped instance needs to be set afterwards.
      参数:
        `registerDefaultEditors` - whether to register default editors (can be suppressed if the BeanWrapper won't need any type conversion)
      另请参阅:
        `setWrappedInstance(java.lang.Object, java.lang.String, java.lang.Object)`

    - #### BeanWrapperImpl

          public BeanWrapperImpl(Object object)

      Create a new BeanWrapperImpl for the given object.
      参数:
        `object` - object wrapped by this BeanWrapper

    - #### BeanWrapperImpl

          public BeanWrapperImpl(Class<?> clazz)

      Create a new BeanWrapperImpl, wrapping a new instance of the specified class.
      参数:
        `clazz` - class to instantiate and wrap

    - #### BeanWrapperImpl

          public BeanWrapperImpl(Object object,
                                 String nestedPath,
                                 Object rootObject)

      Create a new BeanWrapperImpl for the given object, registering a nested path that the object is in.
      参数:
        `object` - object wrapped by this BeanWrapper
        `nestedPath` - the nested path of the object
        `rootObject` - the root object at the top of the path

  - ### 方法详细资料

    - #### setBeanInstance

          public void setBeanInstance(Object object)

      Set a bean instance to hold, without any unwrapping of `Optional`.
      参数:
        `object` - the actual target object
      从以下版本开始:
        4.3
      另请参阅:
        `AbstractNestablePropertyAccessor.setWrappedInstance(Object)`

    - #### setWrappedInstance

          public void setWrappedInstance(Object object,
                                         @Nullable
                                         String nestedPath,
                                         @Nullable
                                         Object rootObject)

      从类复制的说明: `AbstractNestablePropertyAccessor`
      Switch the target object, replacing the cached introspection results only if the class of the new object is different to that of the replaced object.
      覆盖:
        `setWrappedInstance` 在类中 `AbstractNestablePropertyAccessor`
      参数:
        `object` - the new target object
        `nestedPath` - the nested path of the object
        `rootObject` - the root object at the top of the path

    - #### setIntrospectionClass

          protected void setIntrospectionClass(Class<?> clazz)

      Set the class to introspect. Needs to be called when the target object changes.
      参数:
        `clazz` - the class to introspect

    - #### setSecurityContext

          public void setSecurityContext(@Nullable
                                         AccessControlContext acc)

      Set the security context used during the invocation of the wrapped instance methods. Can be null.

    - #### getSecurityContext

          @Nullable
          public AccessControlContext getSecurityContext()

      Return the security context used during the invocation of the wrapped instance methods. Can be null.

    - #### convertForProperty

          @Nullable
          public Object convertForProperty(@Nullable
                                                      Object value,
                                                      String propertyName)
                                               throws TypeMismatchException

      Convert the given value for the specified property to the latter's type.

      This method is only intended for optimizations in a BeanFactory. Use the `convertIfNecessary` methods for programmatic conversion.

      参数:
        `value` - the value to convert
        `propertyName` - the target property (note that nested or indexed properties are not supported here)
      返回:
        the new value, possibly the result of type conversion
      抛出:
        `TypeMismatchException` - if type conversion failed

    - #### getLocalPropertyHandler

          @Nullable
          protected org.springframework.beans.BeanWrapperImpl.BeanPropertyHandler getLocalPropertyHandler(String propertyName)

      从类复制的说明: `AbstractNestablePropertyAccessor`
      Return a `AbstractNestablePropertyAccessor.PropertyHandler` for the specified local `propertyName`. Only used to reach a property available in the current context.
      指定者:
        `getLocalPropertyHandler` 在类中 `AbstractNestablePropertyAccessor`
      参数:
        `propertyName` - the name of a local property
      返回:
        the handler for that property, or `null` if it has not been found

    - #### newNestedPropertyAccessor

          protected BeanWrapperImpl newNestedPropertyAccessor(Object object,
                                                              String nestedPath)

      从类复制的说明: `AbstractNestablePropertyAccessor`
      Create a new nested property accessor instance. Can be overridden in subclasses to create a PropertyAccessor subclass.
      指定者:
        `newNestedPropertyAccessor` 在类中 `AbstractNestablePropertyAccessor`
      参数:
        `object` - object wrapped by this PropertyAccessor
        `nestedPath` - the nested path of the object
      返回:
        the nested PropertyAccessor instance

    - #### createNotWritablePropertyException

          protected NotWritablePropertyException createNotWritablePropertyException(String propertyName)

      从类复制的说明: `AbstractNestablePropertyAccessor`
      Create a `NotWritablePropertyException` for the specified property.
      指定者:
        `createNotWritablePropertyException` 在类中 `AbstractNestablePropertyAccessor`

    - #### getPropertyDescriptors

          public PropertyDescriptor[] getPropertyDescriptors()

      从接口复制的说明: `BeanWrapper`
      Obtain the PropertyDescriptors for the wrapped object (as determined by standard JavaBeans introspection).
      指定者:
        `getPropertyDescriptors` 在接口中 `BeanWrapper`
      返回:
        the PropertyDescriptors for the wrapped object

    - #### getPropertyDescriptor

          public PropertyDescriptor getPropertyDescriptor(String propertyName)
                                                   throws InvalidPropertyException

      从接口复制的说明: `BeanWrapper`
      Obtain the property descriptor for a specific property of the wrapped object.
      指定者:
        `getPropertyDescriptor` 在接口中 `BeanWrapper`
      参数:
        `propertyName` - the property to obtain the descriptor for (may be a nested path, but no indexed/mapped property)
      返回:
        the property descriptor for the specified property
      抛出:
        `InvalidPropertyException` - if there is no such property