1 /* 2 * Copyright 2002-2014 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package org.springframework.beans; 18 19 import java.beans.PropertyDescriptor; 20 21 /** 22 * The central interface of Spring's low-level JavaBeans infrastructure. 23 * 24 * <p>Typically not used directly but rather implicitly via a 25 * {@link org.springframework.beans.factory.BeanFactory} or a 26 * {@link org.springframework.validation.DataBinder}. 27 * 28 * <p>Provides operations to analyze and manipulate standard JavaBeans: 29 * the ability to get and set property values (individually or in bulk), 30 * get property descriptors, and query the readability/writability of properties. 31 * 32 * <p>This interface supports <b>nested properties</b> enabling the setting 33 * of properties on subproperties to an unlimited depth. 34 * 35 * <p>A BeanWrapper's default for the "extractOldValueForEditor" setting 36 * is "false", to avoid side effects caused by getter method invocations. 37 * Turn this to "true" to expose present property values to custom editors. 38 * 39 * @author Rod Johnson 40 * @author Juergen Hoeller 41 * @since 13 April 2001 42 * @see PropertyAccessor 43 * @see PropertyEditorRegistry 44 * @see PropertyAccessorFactory#forBeanPropertyAccess 45 * @see org.springframework.beans.factory.BeanFactory 46 * @see org.springframework.validation.BeanPropertyBindingResult 47 * @see org.springframework.validation.DataBinder#initBeanPropertyAccess() 48 */ 49 public interface BeanWrapper extends ConfigurablePropertyAccessor { 50 51 /** 52 * Return the bean instance wrapped by this object, if any. 53 * @return the bean instance, or {@code null} if none set 54 */ 55 Object getWrappedInstance(); 56 57 /** 58 * Return the type of the wrapped JavaBean object. 59 * @return the type of the wrapped bean instance, 60 * or {@code null} if no wrapped object has been set 61 */ 62 Class<?> getWrappedClass(); 63 64 /** 65 * Obtain the PropertyDescriptors for the wrapped object 66 * (as determined by standard JavaBeans introspection). 67 * @return the PropertyDescriptors for the wrapped object 68 */ 69 PropertyDescriptor[] getPropertyDescriptors(); 70 71 /** 72 * Obtain the property descriptor for a specific property 73 * of the wrapped object. 74 * @param propertyName the property to obtain the descriptor for 75 * (may be a nested path, but no indexed/mapped property) 76 * @return the property descriptor for the specified property 77 * @throws InvalidPropertyException if there is no such property 78 */ 79 PropertyDescriptor getPropertyDescriptor(String propertyName) throws InvalidPropertyException; 80 81 /** 82 * Specify a limit for array and collection auto-growing. 83 * <p>Default is unlimited on a plain BeanWrapper. 84 */ 85 void setAutoGrowCollectionLimit(int autoGrowCollectionLimit); 86 87 /** 88 * Return the limit for array and collection auto-growing. 89 */ 90 int getAutoGrowCollectionLimit(); 91 92 }