KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > dao > IncorrectResultSizeDataAccessException


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.dao;
18
19 /**
20  * Data access exception thrown when a result was not of the expected size,
21  * for example when expecting a single row but getting 0 or more than 1 rows.
22  *
23  * @author Juergen Hoeller
24  * @since 1.0.2
25  * @see EmptyResultDataAccessException
26  */

27 public class IncorrectResultSizeDataAccessException extends DataRetrievalFailureException {
28
29     private int expectedSize;
30
31     private int actualSize;
32
33
34     /**
35      * Constructor for IncorrectResultSizeDataAccessException.
36      * @param expectedSize the expected result size
37      */

38     public IncorrectResultSizeDataAccessException(int expectedSize) {
39         super("Incorrect result size: expected " + expectedSize);
40         this.expectedSize = expectedSize;
41         this.actualSize = -1;
42     }
43
44     /**
45      * Constructor for IncorrectResultSizeDataAccessException.
46      * @param expectedSize the expected result size
47      * @param actualSize the actual result size (or -1 if unknown)
48      */

49     public IncorrectResultSizeDataAccessException(int expectedSize, int actualSize) {
50         super("Incorrect result size: expected " + expectedSize + ", actual " + actualSize);
51         this.expectedSize = expectedSize;
52         this.actualSize = actualSize;
53     }
54
55     /**
56      * Constructor for IncorrectResultSizeDataAccessException.
57      * @param msg the detail message
58      * @param expectedSize the expected result size
59      */

60     public IncorrectResultSizeDataAccessException(String JavaDoc msg, int expectedSize) {
61         super(msg);
62         this.expectedSize = expectedSize;
63         this.actualSize = -1;
64     }
65
66     /**
67      * Constructor for IncorrectResultSizeDataAccessException.
68      * @param msg the detail message
69      * @param expectedSize the expected result size
70      * @param actualSize the actual result size (or -1 if unknown)
71      */

72     public IncorrectResultSizeDataAccessException(String JavaDoc msg, int expectedSize, int actualSize) {
73         super(msg);
74         this.expectedSize = expectedSize;
75         this.actualSize = actualSize;
76     }
77
78
79     /**
80      * Return the expected result size.
81      */

82     public int getExpectedSize() {
83         return expectedSize;
84     }
85
86     /**
87      * Return the actual result size (or -1 if unknown).
88      */

89     public int getActualSize() {
90         return actualSize;
91     }
92
93 }
94
Popular Tags