01 /*
02 * Copyright 2010-2013 the original author or authors.
03 *
04 * Licensed under the Apache License, Version 2.0 (the "License");
05 * you may not use this file except in compliance with the License.
06 * You may obtain a copy of the License at
07 *
08 * http://www.apache.org/licenses/LICENSE-2.0
09 *
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 griffon.core.resources;
18
19 import java.util.Locale;
20
21 /**
22 * @author Andres Almiray
23 * @author Alexander Klein
24 * @since 1.1.0
25 */
26 public class NoSuchResourceException extends RuntimeException {
27 private String key;
28 private Locale locale;
29
30 /**
31 * Create a new exception.
32 *
33 * @param key message that could not be resolved for given locale
34 * @param locale locale that was used to search for the code within
35 */
36 public NoSuchResourceException(String key, Locale locale) {
37 super("No resorce found under key '" + key + "' for locale '" + locale + "'.");
38 this.key = key;
39 this.locale = locale;
40 }
41
42 /**
43 * Create a new exception.
44 *
45 * @param key key that could not be resolved for given locale
46 */
47 public NoSuchResourceException(String key) {
48 this(key, Locale.getDefault());
49 }
50
51 /**
52 * Get the key without a valid value
53 *
54 * @return The key
55 */
56 public String getKey() {
57 return key;
58 }
59
60 /**
61 * Get the locale without a valid value
62 *
63 * @return The locale
64 */
65 public Locale getLocale() {
66 return locale;
67 }
68 }
|