01: /*
02: * Copyright 2002-2006 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: /**
20: * Exception thrown on an attempt to set the value of a property
21: * that isn't writable, because there's no setter method. In some
22: * situations alternatives are presented.
23: *
24: * @author Rod Johnson
25: * @author Alef Arendsen
26: * @author Arjen Poutsma
27: */
28: public class NotWritablePropertyException extends
29: InvalidPropertyException {
30:
31: private String[] possibleMatches = null;
32:
33: /**
34: * Create a new NotWritablePropertyException.
35: * @param beanClass the offending bean class
36: * @param propertyName the offending property name
37: */
38: public NotWritablePropertyException(Class beanClass,
39: String propertyName) {
40: super (
41: beanClass,
42: propertyName,
43: "Bean property '"
44: + propertyName
45: + "' is not writable or has an invalid setter method: "
46: + "Does the return type of the getter match the parameter type of the setter?");
47: }
48:
49: /**
50: * Create a new NotWritablePropertyException.
51: * @param beanClass the offending bean class
52: * @param propertyName the offending property name
53: * @param msg the detail message
54: */
55: public NotWritablePropertyException(Class beanClass,
56: String propertyName, String msg) {
57: super (beanClass, propertyName, msg);
58: }
59:
60: /**
61: * Create a new NotWritablePropertyException.
62: * @param beanClass the offending bean class
63: * @param propertyName the offending property name
64: * @param msg the detail message
65: * @param cause the root cause
66: */
67: public NotWritablePropertyException(Class beanClass,
68: String propertyName, String msg, Throwable cause) {
69: super (beanClass, propertyName, msg, cause);
70: }
71:
72: /**
73: * Create a new NotWritablePropertyException.
74: * @param beanClass the offending bean class
75: * @param propertyName the offending property name
76: * @param msg the detail message
77: * @param possibleMatches suggestions for actual bean property names
78: * that closely match the invalid property name
79: */
80: public NotWritablePropertyException(Class beanClass,
81: String propertyName, String msg, String[] possibleMatches) {
82: super (beanClass, propertyName, msg);
83: this .possibleMatches = possibleMatches;
84: }
85:
86: /**
87: * Return suggestions for actual bean property names that closely match
88: * the invalid property name, if any.
89: */
90: public String[] getPossibleMatches() {
91: return possibleMatches;
92: }
93:
94: }
|