01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: * A <code>BeanWrapper</code> instance can be used repeatedly, with its
35: * {@link #setWrappedInstance(Object) target object} (the wrapped JavaBean
36: * instance) changing as required.
37: *
38: * <p>A BeanWrapper's default for the "extractOldValueForEditor" setting
39: * is "false", to avoid side effects caused by getter method invocations.
40: * Turn this to "true" to expose present property values to custom editors.
41: *
42: * @author Rod Johnson
43: * @author Juergen Hoeller
44: * @since 13 April 2001
45: * @see #setExtractOldValueForEditor
46: * @see PropertyAccessor
47: * @see PropertyEditorRegistry
48: * @see BeanWrapperImpl
49: * @see org.springframework.beans.factory.BeanFactory
50: * @see org.springframework.validation.BeanPropertyBindingResult
51: * @see org.springframework.validation.DataBinder#initBeanPropertyAccess()
52: */
53: public interface BeanWrapper extends ConfigurablePropertyAccessor,
54: TypeConverter {
55:
56: /**
57: * Change the wrapped JavaBean object.
58: * @param obj the bean instance to wrap
59: */
60: void setWrappedInstance(Object obj);
61:
62: /**
63: * Return the bean instance wrapped by this object, if any.
64: * @return the bean instance, or <code>null</code> if none set
65: */
66: Object getWrappedInstance();
67:
68: /**
69: * Return the type of the wrapped JavaBean object.
70: * @return the type of the wrapped bean instance,
71: * or <code>null</code> if no wrapped object has been set
72: */
73: Class getWrappedClass();
74:
75: /**
76: * Obtain the PropertyDescriptors for the wrapped object
77: * (as determined by standard JavaBeans introspection).
78: * @return the PropertyDescriptors for the wrapped object
79: */
80: PropertyDescriptor[] getPropertyDescriptors();
81:
82: /**
83: * Obtain the property descriptor for a specific property
84: * of the wrapped object.
85: * @param propertyName the property to obtain the descriptor for
86: * (may be a nested path, but no indexed/mapped property)
87: * @return the property descriptor for the specified property
88: * @throws InvalidPropertyException if there is no such property
89: */
90: PropertyDescriptor getPropertyDescriptor(String propertyName)
91: throws BeansException;
92:
93: }
|