001/*
002 * Copyright 2002-2017 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.
066         */
067        Object getWrappedInstance();
068
069        /**
070         * Return the type of the wrapped bean instance.
071         */
072        Class<?> getWrappedClass();
073
074        /**
075         * Obtain the PropertyDescriptors for the wrapped object
076         * (as determined by standard JavaBeans introspection).
077         * @return the PropertyDescriptors for the wrapped object
078         */
079        PropertyDescriptor[] getPropertyDescriptors();
080
081        /**
082         * Obtain the property descriptor for a specific property
083         * of the wrapped object.
084         * @param propertyName the property to obtain the descriptor for
085         * (may be a nested path, but no indexed/mapped property)
086         * @return the property descriptor for the specified property
087         * @throws InvalidPropertyException if there is no such property
088         */
089        PropertyDescriptor getPropertyDescriptor(String propertyName) throws InvalidPropertyException;
090
091}