org.springframework.beans

Class BeanWrapperImpl

    • Constructor Detail

      • BeanWrapperImpl

        public BeanWrapperImpl(boolean registerDefaultEditors)
        Create a new empty BeanWrapperImpl. Wrapped instance needs to be set afterwards.
        Parameters:
        registerDefaultEditors - whether to register default editors (can be suppressed if the BeanWrapper won't need any type conversion)
        See Also:
        setWrappedInstance(java.lang.Object, java.lang.String, java.lang.Object)
      • BeanWrapperImpl

        public BeanWrapperImpl(java.lang.Object object)
        Create a new BeanWrapperImpl for the given object.
        Parameters:
        object - object wrapped by this BeanWrapper
      • BeanWrapperImpl

        public BeanWrapperImpl(java.lang.Class<?> clazz)
        Create a new BeanWrapperImpl, wrapping a new instance of the specified class.
        Parameters:
        clazz - class to instantiate and wrap
      • BeanWrapperImpl

        public BeanWrapperImpl(java.lang.Object object,
                               java.lang.String nestedPath,
                               java.lang.Object rootObject)
        Create a new BeanWrapperImpl for the given object, registering a nested path that the object is in.
        Parameters:
        object - object wrapped by this BeanWrapper
        nestedPath - the nested path of the object
        rootObject - the root object at the top of the path
    • Method Detail

      • setWrappedInstance

        public void setWrappedInstance(java.lang.Object object,
                                       @Nullable
                                       java.lang.String nestedPath,
                                       @Nullable
                                       java.lang.Object rootObject)
        Description copied from class: 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.
        Overrides:
        setWrappedInstance in class AbstractNestablePropertyAccessor
        Parameters:
        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(java.lang.Class<?> clazz)
        Set the class to introspect. Needs to be called when the target object changes.
        Parameters:
        clazz - the class to introspect
      • setSecurityContext

        public void setSecurityContext(@Nullable
                                       java.security.AccessControlContext acc)
        Set the security context used during the invocation of the wrapped instance methods. Can be null.
      • getSecurityContext

        @Nullable
        public java.security.AccessControlContext getSecurityContext()
        Return the security context used during the invocation of the wrapped instance methods. Can be null.
      • convertForProperty

        @Nullable
        public java.lang.Object convertForProperty(@Nullable
                                                             java.lang.Object value,
                                                             java.lang.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.

        Parameters:
        value - the value to convert
        propertyName - the target property (note that nested or indexed properties are not supported here)
        Returns:
        the new value, possibly the result of type conversion
        Throws:
        TypeMismatchException - if type conversion failed
      • newNestedPropertyAccessor

        protected BeanWrapperImpl newNestedPropertyAccessor(java.lang.Object object,
                                                            java.lang.String nestedPath)
        Description copied from class: AbstractNestablePropertyAccessor
        Create a new nested property accessor instance. Can be overridden in subclasses to create a PropertyAccessor subclass.
        Specified by:
        newNestedPropertyAccessor in class AbstractNestablePropertyAccessor
        Parameters:
        object - object wrapped by this PropertyAccessor
        nestedPath - the nested path of the object
        Returns:
        the nested PropertyAccessor instance
      • getPropertyDescriptors

        public java.beans.PropertyDescriptor[] getPropertyDescriptors()
        Description copied from interface: BeanWrapper
        Obtain the PropertyDescriptors for the wrapped object (as determined by standard JavaBeans introspection).
        Specified by:
        getPropertyDescriptors in interface BeanWrapper
        Returns:
        the PropertyDescriptors for the wrapped object
      • getPropertyDescriptor

        public java.beans.PropertyDescriptor getPropertyDescriptor(java.lang.String propertyName)
                                                            throws InvalidPropertyException
        Description copied from interface: BeanWrapper
        Obtain the property descriptor for a specific property of the wrapped object.
        Specified by:
        getPropertyDescriptor in interface BeanWrapper
        Parameters:
        propertyName - the property to obtain the descriptor for (may be a nested path, but no indexed/mapped property)
        Returns:
        the property descriptor for the specified property
        Throws:
        InvalidPropertyException - if there is no such property