KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > beans > NotWritablePropertyException


1 /*
2  * Copyright 2002-2006 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 /**
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 InvalidPropertyException {
29
30     private String JavaDoc[] possibleMatches = null;
31
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 JavaDoc beanClass, String JavaDoc propertyName) {
39         super(beanClass, propertyName,
40                 "Bean property '" + propertyName + "' is not writable or has an invalid setter method: " +
41                 "Does the return type of the getter match the parameter type of the setter?");
42     }
43
44     /**
45      * Create a new NotWritablePropertyException.
46      * @param beanClass the offending bean class
47      * @param propertyName the offending property name
48      * @param msg the detail message
49      */

50     public NotWritablePropertyException(Class JavaDoc beanClass, String JavaDoc propertyName, String JavaDoc msg) {
51         super(beanClass, propertyName, msg);
52     }
53
54     /**
55      * Create a new NotWritablePropertyException.
56      * @param beanClass the offending bean class
57      * @param propertyName the offending property name
58      * @param msg the detail message
59      * @param cause the root cause
60      */

61     public NotWritablePropertyException(Class JavaDoc beanClass, String JavaDoc propertyName, String JavaDoc msg, Throwable JavaDoc cause) {
62         super(beanClass, propertyName, msg, cause);
63     }
64
65     /**
66      * Create a new NotWritablePropertyException.
67      * @param beanClass the offending bean class
68      * @param propertyName the offending property name
69      * @param msg the detail message
70      * @param possibleMatches suggestions for actual bean property names
71      * that closely match the invalid property name
72      */

73     public NotWritablePropertyException(Class JavaDoc beanClass, String JavaDoc propertyName, String JavaDoc msg, String JavaDoc[] possibleMatches) {
74         super(beanClass, propertyName, msg);
75         this.possibleMatches = possibleMatches;
76     }
77
78
79     /**
80      * Return suggestions for actual bean property names that closely match
81      * the invalid property name, if any.
82      */

83     public String JavaDoc[] getPossibleMatches() {
84         return possibleMatches;
85     }
86
87 }
88
Popular Tags