KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > reflect > PropertyException


1 /*****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  ****************************************************************/

19
20 package org.apache.cayenne.reflect;
21
22 import org.apache.cayenne.CayenneRuntimeException;
23
24 /**
25  * An unchecked exception thrown on errors during property access, either within a
26  * Accessor or a Property.
27  *
28  * @since 3.0
29  * @author Andrus Adamchik
30  */

31 public class PropertyException extends CayenneRuntimeException {
32
33     protected Property property;
34     protected Accessor accessor;
35     protected Object JavaDoc source;
36
37     public PropertyException(String JavaDoc message) {
38         this(message, null);
39     }
40
41     public PropertyException(String JavaDoc message, Throwable JavaDoc cause) {
42         super(message, cause);
43     }
44
45     public PropertyException(String JavaDoc message, Accessor accessor, Object JavaDoc source) {
46         this(message, accessor, source, null);
47     }
48
49     public PropertyException(String JavaDoc message, Accessor accessor, Object JavaDoc source,
50             Throwable JavaDoc cause) {
51         super(message, cause);
52
53         this.accessor = accessor;
54         this.source = source;
55     }
56
57     public PropertyException(String JavaDoc message, Property property, Object JavaDoc source) {
58         this(message, property, source, null);
59     }
60
61     public PropertyException(String JavaDoc message, Property property, Object JavaDoc source,
62             Throwable JavaDoc cause) {
63         super(message, cause);
64
65         this.property = property;
66         this.source = source;
67     }
68
69     /**
70      * Returns property descriptor that was used to access the property. It may be null.
71      */

72     public Accessor getAccessor() {
73         return accessor;
74     }
75
76     public Property getProperty() {
77         return property;
78     }
79
80     /**
81      * Returns an object that caused an error.
82      */

83     public Object JavaDoc getSource() {
84         return source;
85     }
86 }
87
Popular Tags