001/*
002 * Copyright 2002-2016 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.beans;
018
019import java.beans.PropertyDescriptor;
020
021/**
022 * The central interface of Spring's low-level JavaBeans infrastructure.
023 *
024 * <p>Typically not used directly but rather implicitly via a
025 * {@link org.springframework.beans.factory.BeanFactory} or a
026 * {@link org.springframework.validation.DataBinder}.
027 *
028 * <p>Provides operations to analyze and manipulate standard JavaBeans:
029 * the ability to get and set property values (individually or in bulk),
030 * get property descriptors, and query the readability/writability of properties.
031 *
032 * <p>This interface supports <b>nested properties</b> enabling the setting
033 * of properties on subproperties to an unlimited depth.
034 *
035 * <p>A BeanWrapper's default for the "extractOldValueForEditor" setting
036 * is "false", to avoid side effects caused by getter method invocations.
037 * Turn this to "true" to expose present property values to custom editors.
038 *
039 * @author Rod Johnson
040 * @author Juergen Hoeller
041 * @since 13 April 2001
042 * @see PropertyAccessor
043 * @see PropertyEditorRegistry
044 * @see PropertyAccessorFactory#forBeanPropertyAccess
045 * @see org.springframework.beans.factory.BeanFactory
046 * @see org.springframework.validation.BeanPropertyBindingResult
047 * @see org.springframework.validation.DataBinder#initBeanPropertyAccess()
048 */
049public interface BeanWrapper extends ConfigurablePropertyAccessor {
050
051        /**
052         * Specify a limit for array and collection auto-growing.
053         * <p>Default is unlimited on a plain BeanWrapper.
054         * @since 4.1
055         */
056        void setAutoGrowCollectionLimit(int autoGrowCollectionLimit);
057
058        /**
059         * Return the limit for array and collection auto-growing.
060         * @since 4.1
061         */
062        int getAutoGrowCollectionLimit();
063
064        /**
065         * Return the bean instance wrapped by this object, if any.
066         * @return the bean instance, or {@code null} if none set
067         */
068        Object getWrappedInstance();
069
070        /**
071         * Return the type of the wrapped JavaBean object.
072         * @return the type of the wrapped bean instance,
073         * or {@code null} if no wrapped object has been set
074         */
075        Class<?> getWrappedClass();
076
077        /**
078         * Obtain the PropertyDescriptors for the wrapped object
079         * (as determined by standard JavaBeans introspection).
080         * @return the PropertyDescriptors for the wrapped object
081         */
082        PropertyDescriptor[] getPropertyDescriptors();
083
084        /**
085         * Obtain the property descriptor for a specific property
086         * of the wrapped object.
087         * @param propertyName the property to obtain the descriptor for
088         * (may be a nested path, but no indexed/mapped property)
089         * @return the property descriptor for the specified property
090         * @throws InvalidPropertyException if there is no such property
091         */
092        PropertyDescriptor getPropertyDescriptor(String propertyName) throws InvalidPropertyException;
093
094}