KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > binding > format > InvalidFormatException


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 package org.springframework.binding.format;
17
18 import org.springframework.core.NestedRuntimeException;
19
20 /**
21  * Thrown when a formatted value is of the wrong form.
22  *
23  * @author Keith Donald
24  */

25 public class InvalidFormatException extends NestedRuntimeException {
26
27     private String JavaDoc invalidValue;
28
29     private String JavaDoc expectedFormat;
30
31     public InvalidFormatException(String JavaDoc invalidValue, String JavaDoc expectedFormat) {
32         this(invalidValue, expectedFormat, (Throwable JavaDoc)null);
33     }
34
35     public InvalidFormatException(String JavaDoc invalidValue, String JavaDoc expectedFormat, Throwable JavaDoc cause) {
36         super("Invalid format for value " + invalidValue + "; the expected format was '" + expectedFormat + "'", cause);
37         this.invalidValue = invalidValue;
38         this.expectedFormat = expectedFormat;
39     }
40
41     public InvalidFormatException(String JavaDoc invalidValue, String JavaDoc expectedFormat, String JavaDoc message, Throwable JavaDoc cause) {
42         super(message, cause);
43         this.invalidValue = invalidValue;
44         this.expectedFormat = expectedFormat;
45     }
46
47     public String JavaDoc getInvalidValue() {
48         return invalidValue;
49     }
50
51     public String JavaDoc getExpectedFormat() {
52         return expectedFormat;
53     }
54 }
Popular Tags