View Javadoc

1   /*   Copyright (C) 2004 Finalist IT Group
2    *
3    *   This file is part of JAG - the Java J2EE Application Generator
4    *
5    *   JAG is free software; you can redistribute it and/or modify
6    *   it under the terms of the GNU General Public License as published by
7    *   the Free Software Foundation; either version 2 of the License, or
8    *   (at your option) any later version.
9    *   JAG is distributed in the hope that it will be useful,
10   *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   *   GNU General Public License for more details.
13   *   You should have received a copy of the GNU General Public License
14   *   along with JAG; if not, write to the Free Software
15   *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16   */
17  
18  package com.finalist.tools.database;
19  
20  /***
21   * NotMappableException. Exception that is thrown when no mapping could
22   * be found by the RowMapper object.
23   *
24   * @author  P.S.D.Reitsma, Finalist IT Group
25   * @version 1.0
26   */
27  public class NotMappableException extends Exception {
28  
29     boolean duringBind;
30  
31     String source;
32  
33     String targetName;
34     String targetType;
35     String targetValue;
36  
37     String sourceName;
38     String sourceType;
39     String sourceValue;
40  
41     String rootExceptionName;
42  
43     String message;
44  
45  
46     NotMappableException() {
47     }
48  
49  
50     NotMappableException(String message) {
51        this.message = message;
52     }
53  
54  
55     /*** Getter for property rootExceptionName.
56      * @return Value of property rootExceptionName.
57      */
58     String getRootExceptionName() {
59        return rootExceptionName;
60     }
61  
62  
63     /*** Setter for property rootExceptionName.
64      * @param rootExceptionName New value of property rootExceptionName.
65      */
66     void setRootExceptionName(String rootExceptionName) {
67        this.rootExceptionName = rootExceptionName;
68     }
69  
70  
71     /*** Getter for property source.
72      * @return Value of property source.
73      */
74     String getSource() {
75        return source;
76     }
77  
78  
79     /*** Setter for property source.
80      * @param source New value of property source.
81      */
82     void setSource(String source) {
83        this.source = source;
84     }
85  
86  
87     /*** Getter for property sourceName.
88      * @return Value of property sourceName.
89      */
90     String getSourceName() {
91        return sourceName;
92     }
93  
94  
95     /*** Setter for property sourceName.
96      * @param sourceName New value of property sourceName.
97      */
98     void setSourceName(String sourceName) {
99        this.sourceName = sourceName;
100    }
101 
102 
103    /*** Getter for property sourceType.
104     * @return Value of property sourceType.
105     */
106    String getSourceType() {
107       return sourceType;
108    }
109 
110 
111    /*** Setter for property sourceType.
112     * @param sourceType New value of property sourceType.
113     */
114    void setSourceType(String sourceType) {
115       this.sourceType = sourceType;
116    }
117 
118 
119    /*** Getter for property sourceValue.
120     * @return Value of property sourceValue.
121     */
122    String getSourceValue() {
123       return sourceValue;
124    }
125 
126 
127    /*** Setter for property sourceValue.
128     * @param sourceValue New value of property sourceValue.
129     */
130    void setSourceValue(String sourceValue) {
131       this.sourceValue = sourceValue;
132    }
133 
134 
135    /*** Getter for property targetName.
136     * @return Value of property targetName.
137     */
138    String getTargetName() {
139       return targetName;
140    }
141 
142 
143    /*** Setter for property targetName.
144     * @param targetName New value of property targetName.
145     */
146    void setTargetName(String targetName) {
147       this.targetName = targetName;
148    }
149 
150 
151    /*** Getter for property targetType.
152     * @return Value of property targetType.
153     */
154    String getTargetType() {
155       return targetType;
156    }
157 
158 
159    /*** Setter for property targetType.
160     * @param targetType New value of property targetType.
161     */
162    void setTargetType(String targetType) {
163       this.targetType = targetType;
164    }
165 
166 
167    /*** Getter for property targetValue.
168     * @return Value of property targetValue.
169     */
170    String getTargetValue() {
171       return targetValue;
172    }
173 
174 
175    /*** Setter for property targetValue.
176     * @param targetValue New value of property targetValue.
177     */
178    void setTargetValue(String targetValue) {
179       this.targetValue = targetValue;
180    }
181 
182 
183    public String getMessage() {
184       if (this.message == null) {
185          StringBuffer message = new StringBuffer();
186          if (duringBind == true) {
187             message.append("Object " + sourceName + " of type " + sourceType + " could not be mapped");
188             message.append(" to column " + targetName);
189          }
190          else {
191             message.append("Column " + sourceName + " of type " + sourceType + " could not be mapped");
192             message.append(" to target type " + targetType);
193          }
194          return message.toString();
195       }
196       else {
197          return message;
198       }
199    }
200 
201 
202    void setMessage(String message) {
203       this.message = message;
204    }
205 
206 
207    /*** Getter for property duringBind.
208     * @return Value of property duringBind.
209     */
210    boolean isDuringBind() {
211       return duringBind;
212    }
213 
214 
215    /*** Setter for property duringBind.
216     * @param duringBind New value of property duringBind.
217     */
218    void setDuringBind(boolean duringBind) {
219       this.duringBind = duringBind;
220    }
221 
222 }